[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.ITERATION;
|
---|
| 20 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SELECTION;
|
---|
| 21 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SEQUENCE;
|
---|
[1170] | 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 {" +
|
---|
[1319] | 44 | " Sequence seq1 {" +
|
---|
[1170] | 45 | " TextInput t1 {}" +
|
---|
| 46 | " Selection sel1 {" +
|
---|
| 47 | " Sequence seq2 {" +
|
---|
| 48 | " MouseClick t2 {}" +
|
---|
| 49 | " TextInput t3 {}" +
|
---|
| 50 | " }" +
|
---|
| 51 | " }" +
|
---|
[1319] | 52 | " Iteration iter1 {" +
|
---|
[1170] | 53 | " MouseClick t2 {}" +
|
---|
| 54 | " }" +
|
---|
| 55 | " }" +
|
---|
| 56 | " TextInput t3 {}" +
|
---|
| 57 | " MouseClick t2 {}" +
|
---|
| 58 | " Iteration iter1 {" +
|
---|
[1319] | 59 | " MouseClick t2 {}" +
|
---|
[1170] | 60 | " }" +
|
---|
| 61 | "}";
|
---|
| 62 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 63 | InteractionPattern containedPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
| 64 | InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(ITERATION).startsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 65 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsPattern(containedPattern).endsWithPattern(endsWithPattern).patternFinished().build();
|
---|
[1170] | 66 | // When
|
---|
| 67 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 68 | // Then
|
---|
| 69 | assertThat(patternContained).isTrue();
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | @Test
|
---|
| 73 | public void starts_with_event_contains_pattern_ends_with_pattern_negative() {
|
---|
| 74 | // Given
|
---|
| 75 | String spec = "UserSession {" +
|
---|
| 76 | " Sequence seq1 {" +
|
---|
| 77 | " TextInput t1 {}" +
|
---|
| 78 | " Selection sel1{" +
|
---|
| 79 | " TextInput t2 {}" +
|
---|
| 80 | " }" +
|
---|
| 81 | " Selection sel1 {" +
|
---|
| 82 | " MouseClick t3 {}" +
|
---|
| 83 | " }" +
|
---|
| 84 | " }" +
|
---|
| 85 | " TextInput t2 {}" +
|
---|
| 86 | " MouseClick t4 {}" +
|
---|
| 87 | " Iteration iter1 {" +
|
---|
| 88 | " MouseClick t5 {}" +
|
---|
| 89 | " }" +
|
---|
| 90 | "}";
|
---|
| 91 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 92 | InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(ITERATION).startsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 93 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithEvent(TEXT_INPUT).containsEvent(MOUSE_CLICK).endsWithPattern(endsWithPattern).patternFinished().build();
|
---|
[1170] | 94 | // When
|
---|
| 95 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 96 | // Then
|
---|
| 97 | assertThat(patternContained).isFalse();
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | }
|
---|