[1170] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
| 15 | package de.ugoe.cs.autoquest.usability.rules.patterns.visitors.startswith;
|
---|
| 16 |
|
---|
| 17 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.MOUSE_CLICK;
|
---|
| 18 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT;
|
---|
| 19 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.ITERATION;
|
---|
| 20 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE;
|
---|
| 21 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 22 |
|
---|
| 23 | import org.junit.Test;
|
---|
| 24 |
|
---|
| 25 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
| 26 | import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern;
|
---|
| 27 | import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder;
|
---|
| 28 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * <p>
|
---|
| 32 | * TODO comment
|
---|
| 33 | * </p>
|
---|
| 34 | *
|
---|
| 35 | * @author Alexander Deicke
|
---|
| 36 | */
|
---|
| 37 | public class StartsWithEventContainsEventEndsWithPatternTest {
|
---|
| 38 |
|
---|
| 39 | @Test
|
---|
| 40 | public void starts_with_event_contains_event_ends_with_pattern_positive() {
|
---|
| 41 | // Given
|
---|
| 42 | String spec = "UserSession {" +
|
---|
| 43 | " Sequence seq1 {" +
|
---|
| 44 | " TextInput t1 {}" +
|
---|
| 45 | " MouseClick t2 {}" +
|
---|
| 46 | " Iteration {" +
|
---|
| 47 | " MouseClick t3 {}" +
|
---|
| 48 | " }" +
|
---|
| 49 | " }" +
|
---|
| 50 | "}";
|
---|
| 51 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
| 52 | UsagePatternBuilder builder = new UsagePatternBuilder();
|
---|
| 53 | UsagePattern endsWithPattern = builder.concernedNode(ITERATION).startsWith(MOUSE_CLICK).build();
|
---|
| 54 | UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).startsWith(TEXT_INPUT).endsWith(endsWithPattern).build();
|
---|
| 55 | // When
|
---|
| 56 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 57 | // Then
|
---|
| 58 | assertThat(patternContained).isTrue();
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | @Test
|
---|
| 62 | public void starts_with_event_contains_event_ends_with_pattern_negative() {
|
---|
| 63 | // Given
|
---|
| 64 | String spec = "UserSession {" +
|
---|
| 65 | " Sequence seq1 {" +
|
---|
| 66 | " TextInput t1 {}" +
|
---|
| 67 | " MouseClick t2 {}" +
|
---|
| 68 | " Iteration {" +
|
---|
| 69 | " TextInput t3 {}" +
|
---|
| 70 | " }" +
|
---|
| 71 | " }" +
|
---|
| 72 | "}";
|
---|
| 73 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
| 74 | UsagePatternBuilder builder = new UsagePatternBuilder();
|
---|
| 75 | UsagePattern endsWithPattern = builder.concernedNode(ITERATION).startsWith(MOUSE_CLICK).build();
|
---|
| 76 | UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).startsWith(TEXT_INPUT).endsWith(endsWithPattern).build();
|
---|
| 77 | // When
|
---|
| 78 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 79 | // Then
|
---|
| 80 | assertThat(patternContained).isFalse();
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | }
|
---|