[1151] | 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.endswith;
|
---|
| 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;
|
---|
[1151] | 22 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 23 |
|
---|
| 24 | import org.junit.Test;
|
---|
| 25 |
|
---|
[1205] | 26 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
|
---|
| 27 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
|
---|
[1326] | 28 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1171] | 29 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
[1151] | 30 |
|
---|
| 31 | /**
|
---|
| 32 | * <p>
|
---|
| 33 | * TODO comment
|
---|
| 34 | * </p>
|
---|
| 35 | *
|
---|
| 36 | * @author Alexander Deicke
|
---|
| 37 | */
|
---|
| 38 | public class EndsWithPatternTest {
|
---|
| 39 |
|
---|
| 40 | @Test
|
---|
[1205] | 41 | public void ends_with_pattern_positive() {
|
---|
[1151] | 42 | // Given
|
---|
[1171] | 43 | String spec = "UserSession {" +
|
---|
| 44 | " Sequence seq1 {" +
|
---|
| 45 | " EventTask target2 {}" +
|
---|
| 46 | " EventTask target3 {}" +
|
---|
| 47 | " Selection sel1 {" +
|
---|
| 48 | " Sequence seq2 {" +
|
---|
[1151] | 49 | " TextInput target4 {}" +
|
---|
[1205] | 50 | " MouseClick target5 {}" +
|
---|
[1171] | 51 | " }" +
|
---|
| 52 | " }" +
|
---|
| 53 | " Selection sel1 {" +
|
---|
| 54 | " Sequence seq3 {" +
|
---|
[1151] | 55 | " TextInput target4 {}" +
|
---|
[1205] | 56 | " EventTask target3 {}" +
|
---|
[1151] | 57 | " }" +
|
---|
| 58 | " }" +
|
---|
| 59 | " }" +
|
---|
| 60 | "}";
|
---|
[1171] | 61 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 62 | InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 63 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).endsWithPattern(endsWithPattern).patternFinished().build();
|
---|
[1151] | 64 | // When
|
---|
| 65 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 66 | // Then
|
---|
| 67 | assertThat(patternContained).isTrue();
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | @Test
|
---|
[1205] | 71 | public void ends_with_pattern_negative() {
|
---|
[1151] | 72 | // Given
|
---|
[1171] | 73 | String spec = "UserSession {" +
|
---|
[1205] | 74 | " Sequence seg0 {" +
|
---|
| 75 | " Selection sel1 {" +
|
---|
| 76 | " Sequence seq1 {" +
|
---|
| 77 | " EventTask target1 {}" +
|
---|
[1171] | 78 | " EventTask target2 {}" +
|
---|
| 79 | " }" +
|
---|
[1151] | 80 | " }" +
|
---|
[1205] | 81 | " Selection sel1 {" +
|
---|
| 82 | " Iteration it1 {" +
|
---|
| 83 | " Sequence seq2 {" +
|
---|
| 84 | " MouseClick target5 {}" +
|
---|
| 85 | " EventTask target4 {}" +
|
---|
| 86 | " EventTask target2 {}" +
|
---|
| 87 | " }" +
|
---|
| 88 | " }" +
|
---|
[1151] | 89 | " }" +
|
---|
[1205] | 90 | " Selection sel1 {" +
|
---|
| 91 | " Sequence seq3 {" +
|
---|
| 92 | " EventTask target5 {}" +
|
---|
| 93 | " EventTask target6 {}" +
|
---|
| 94 | " }" +
|
---|
| 95 | " }" +
|
---|
[1151] | 96 | " }" +
|
---|
| 97 | "}";
|
---|
[1171] | 98 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 99 | InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(ITERATION).startsWithEvent(MOUSE_CLICK).containsEvent(TEXT_INPUT).patternFinished().build();
|
---|
| 100 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).endsWithPattern(endsWithPattern).patternFinished().build();
|
---|
[1151] | 101 | // When
|
---|
| 102 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 103 | // Then
|
---|
| 104 | assertThat(patternContained).isFalse();
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | }
|
---|