[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 |
|
---|
| 25 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1205] | 26 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
|
---|
| 27 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
|
---|
[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 StartsWithPatternContainsEventAndEndsWithEventTest {
|
---|
| 38 |
|
---|
| 39 | @Test
|
---|
| 40 | public void starts_with_pattern_contains_event_and_ends_with_event_positive() {
|
---|
| 41 | // Given
|
---|
| 42 | String spec = "UserSession {" +
|
---|
| 43 | " Sequence seq1 {" +
|
---|
| 44 | " Selection sel1 {" +
|
---|
| 45 | " Sequence seq2 {" +
|
---|
[1205] | 46 | " TextInput target1 {}" +
|
---|
[1170] | 47 | " MouseClick target2 {}" +
|
---|
| 48 | " }" +
|
---|
| 49 | " }" +
|
---|
| 50 | " Selection sel1 {" +
|
---|
| 51 | " Sequence seq3 {" +
|
---|
[1205] | 52 | " TextInput target3 {}" +
|
---|
| 53 | " EventTask target4 {}" +
|
---|
[1170] | 54 | " }" +
|
---|
| 55 | " }" +
|
---|
[1205] | 56 | " MouseClick target5 {}" +
|
---|
| 57 | " TextInput target6 {}" +
|
---|
[1170] | 58 | " }" +
|
---|
| 59 | "}";
|
---|
| 60 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 61 | InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 62 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
[1170] | 63 | // When
|
---|
| 64 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 65 | // Then
|
---|
| 66 | assertThat(patternContained).isTrue();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | @Test
|
---|
| 70 | public void starts_with_pattern_contains_event_and_ends_with_event_negative() {
|
---|
| 71 | // Given
|
---|
| 72 | String spec = "UserSession {" +
|
---|
| 73 | " Sequence seq1 {" +
|
---|
| 74 | " Selection sel1 {" +
|
---|
| 75 | " Sequence seq2 {" +
|
---|
| 76 | " TextInput target4 {}" +
|
---|
| 77 | " MouseClick target2 {}" +
|
---|
| 78 | " }" +
|
---|
| 79 | " }" +
|
---|
| 80 | " Selection sel1 {" +
|
---|
| 81 | " Sequence seq3 {" +
|
---|
| 82 | " TextInput target4 {}" +
|
---|
| 83 | " EventTask target2 {}" +
|
---|
| 84 | " }" +
|
---|
| 85 | " }" +
|
---|
| 86 | " EventTask target2 {}" +
|
---|
| 87 | " MouseClick target3 {}" +
|
---|
| 88 | " }" +
|
---|
| 89 | "}";
|
---|
| 90 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 91 | InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 92 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(MOUSE_CLICK).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
[1170] | 93 | // When
|
---|
| 94 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 95 | // Then
|
---|
| 96 | assertThat(patternContained).isFalse();
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | }
|
---|