[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 |
|
---|
[1218] | 17 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.MOUSE_CLICK;
|
---|
| 18 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.TEXT_INPUT;
|
---|
| 19 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SELECTION;
|
---|
| 20 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SEQUENCE;
|
---|
[1170] | 21 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 22 |
|
---|
| 23 | import org.junit.Test;
|
---|
| 24 |
|
---|
[1205] | 25 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
|
---|
| 26 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
|
---|
[1326] | 27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1170] | 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 StartsWithEventContainsPatternAndEndsWithEventTest {
|
---|
| 38 |
|
---|
| 39 | @Test
|
---|
| 40 | public void starts_with_event_contains_pattern_ends_with_pattern_positive() {
|
---|
| 41 | // Given
|
---|
| 42 | String spec = "UserSession {" +
|
---|
| 43 | " Sequence seq1 {" +
|
---|
| 44 | " TextInput t1 {}" +
|
---|
| 45 | " Selection sel1 {" +
|
---|
| 46 | " Sequence seq2 {" +
|
---|
| 47 | " MouseClick t2 {}" +
|
---|
| 48 | " TextInput t3 {}" +
|
---|
| 49 | " }" +
|
---|
| 50 | " }" +
|
---|
| 51 | " Selection sel1 {" +
|
---|
| 52 | " MouseClick t2 {}" +
|
---|
| 53 | " }" +
|
---|
[1205] | 54 | " TextInput t3 {}" +
|
---|
| 55 | " MouseClick t2 {}" +
|
---|
| 56 | " Iteration iter1 {" +
|
---|
| 57 | " TextInput t4 {}" +
|
---|
| 58 | " }" +
|
---|
[1170] | 59 | " }" +
|
---|
| 60 | "}";
|
---|
| 61 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 62 | InteractionPattern containedPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
| 63 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsPattern(containedPattern).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
[1170] | 64 | // When
|
---|
| 65 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 66 | // Then
|
---|
| 67 | assertThat(patternContained).isTrue();
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | @Test
|
---|
| 71 | public void starts_with_event_contains_pattern_ends_with_pattern_negative() {
|
---|
| 72 | // Given
|
---|
| 73 | String spec = "UserSession {" +
|
---|
| 74 | " Sequence seq1 {" +
|
---|
| 75 | " TextInput t1 {}" +
|
---|
| 76 | " Selection sel1 {" +
|
---|
| 77 | " Sequence seq2 {" +
|
---|
| 78 | " MouseClick t2 {}" +
|
---|
| 79 | " TextInput t3 {}" +
|
---|
| 80 | " }" +
|
---|
| 81 | " }" +
|
---|
| 82 | " Selection sel1 {" +
|
---|
| 83 | " MouseClick t2 {}" +
|
---|
| 84 | " }" +
|
---|
| 85 | " }" +
|
---|
| 86 | " TextInput t3 {}" +
|
---|
| 87 | " MouseClick t2 {}" +
|
---|
| 88 | " Iteration iter1 {" +
|
---|
| 89 | " TextInput t4 {}" +
|
---|
| 90 | " }" +
|
---|
| 91 | "}";
|
---|
| 92 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 93 | InteractionPattern containedPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
| 94 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsPattern(containedPattern).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
[1170] | 95 | // When
|
---|
| 96 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 97 | // Then
|
---|
| 98 | assertThat(patternContained).isFalse();
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | }
|
---|