[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.SELECTION;
|
---|
| 21 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE;
|
---|
| 22 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 23 |
|
---|
| 24 | import org.junit.Test;
|
---|
| 25 |
|
---|
| 26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1205] | 27 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
|
---|
| 28 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
|
---|
[1170] | 29 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | * <p>
|
---|
| 33 | * TODO comment
|
---|
| 34 | * </p>
|
---|
| 35 | *
|
---|
| 36 | * @author Alexander Deicke
|
---|
| 37 | */
|
---|
| 38 | public class StartsWithEventContainsPatternAndEndsWithPatternTest {
|
---|
| 39 |
|
---|
| 40 | @Test
|
---|
| 41 | public void starts_with_event_contains_pattern_ends_with_pattern_positive() {
|
---|
| 42 | // Given
|
---|
| 43 | String spec = "UserSession {" +
|
---|
| 44 | " Sequence seq1 {" +
|
---|
| 45 | " TextInput t1 {}" +
|
---|
| 46 | " Selection sel1 {" +
|
---|
| 47 | " Sequence seq2 {" +
|
---|
| 48 | " MouseClick t2 {}" +
|
---|
| 49 | " TextInput t3 {}" +
|
---|
| 50 | " }" +
|
---|
| 51 | " }" +
|
---|
| 52 | " Selection sel1 {" +
|
---|
| 53 | " MouseClick t2 {}" +
|
---|
| 54 | " }" +
|
---|
| 55 | " }" +
|
---|
| 56 | " TextInput t3 {}" +
|
---|
| 57 | " MouseClick t2 {}" +
|
---|
| 58 | " Iteration iter1 {" +
|
---|
| 59 | " MouseClick t4 {}" +
|
---|
| 60 | " }" +
|
---|
| 61 | "}";
|
---|
| 62 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1205] | 63 | InteractionPatternBuilder builder = new InteractionPatternBuilder();
|
---|
| 64 | InteractionPattern containedPattern = builder.concernedNode(SELECTION).startsWith(MOUSE_CLICK).endsWith(TEXT_INPUT).build();
|
---|
| 65 | InteractionPattern endsWithPattern = builder.concernedNode(ITERATION).startsWith(MOUSE_CLICK).build();
|
---|
| 66 | InteractionPattern pattern = new InteractionPatternBuilder().concernedNode(SEQUENCE).startsWith(TEXT_INPUT).contains(containedPattern).endsWith(endsWithPattern).build();
|
---|
[1170] | 67 | // When
|
---|
| 68 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 69 | // Then
|
---|
| 70 | assertThat(patternContained).isTrue();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | @Test
|
---|
| 74 | public void starts_with_event_contains_pattern_ends_with_pattern_negative() {
|
---|
| 75 | // Given
|
---|
| 76 | String spec = "UserSession {" +
|
---|
| 77 | " Sequence seq1 {" +
|
---|
| 78 | " TextInput t1 {}" +
|
---|
| 79 | " Selection sel1{" +
|
---|
| 80 | " TextInput t2 {}" +
|
---|
| 81 | " }" +
|
---|
| 82 | " Selection sel1 {" +
|
---|
| 83 | " MouseClick t3 {}" +
|
---|
| 84 | " }" +
|
---|
| 85 | " }" +
|
---|
| 86 | " TextInput t2 {}" +
|
---|
| 87 | " MouseClick t4 {}" +
|
---|
| 88 | " Iteration iter1 {" +
|
---|
| 89 | " MouseClick t5 {}" +
|
---|
| 90 | " }" +
|
---|
| 91 | "}";
|
---|
| 92 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1205] | 93 | InteractionPatternBuilder builder = new InteractionPatternBuilder();
|
---|
| 94 | InteractionPattern endsWithPattern = builder.concernedNode(ITERATION).startsWith(MOUSE_CLICK).build();
|
---|
| 95 | InteractionPattern pattern = new InteractionPatternBuilder().concernedNode(SEQUENCE).startsWith(TEXT_INPUT).contains(MOUSE_CLICK).endsWith(endsWithPattern).build();
|
---|
[1170] | 96 | // When
|
---|
| 97 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 98 | // Then
|
---|
| 99 | assertThat(patternContained).isFalse();
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | }
|
---|