[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.SCROLL;
|
---|
| 19 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.TEXT_INPUT;
|
---|
| 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 StartsWithPatternContainsEventAndEndsWithPatternTest {
|
---|
| 39 |
|
---|
| 40 | @Test
|
---|
| 41 | public void starts_with_pattern_contains_event_and_ends_with_pattern_positive() {
|
---|
| 42 | // Given
|
---|
| 43 | String spec = "UserSession {" +
|
---|
| 44 | " Sequence seq1 {" +
|
---|
| 45 | " Selection sel1 {" +
|
---|
| 46 | " Sequence seq2{" +
|
---|
| 47 | " TextInput target4 {}" +
|
---|
| 48 | " MouseClick target2 {}" +
|
---|
| 49 | " }" +
|
---|
| 50 | " }" +
|
---|
| 51 | " Selection sel1 {" +
|
---|
| 52 | " Sequence seq3 {" +
|
---|
| 53 | " TextInput target4 {}" +
|
---|
| 54 | " EventTask target2 {}" +
|
---|
| 55 | " }" +
|
---|
| 56 | " }" +
|
---|
[1205] | 57 | " MouseClick target2 {}" +
|
---|
| 58 | " TextInput target3 {}" +
|
---|
| 59 | " Selection sel2 {" +
|
---|
| 60 | " Sequence seq5 {" +
|
---|
| 61 | " TextInput target4 {}" +
|
---|
| 62 | " MouseClick target2 {}" +
|
---|
| 63 | " }" +
|
---|
[1170] | 64 | " }" +
|
---|
[1205] | 65 | " Selection sel2 {" +
|
---|
| 66 | " Sequence seq6 {" +
|
---|
| 67 | " TextInput target4 {}" +
|
---|
| 68 | " EventTask target2 {}" +
|
---|
| 69 | " }" +
|
---|
[1170] | 70 | " }" +
|
---|
| 71 | " }" +
|
---|
| 72 | "}";
|
---|
| 73 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 74 | InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 75 | InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 76 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(MOUSE_CLICK).endsWithPattern(endsWithPattern).patternFinished().build();
|
---|
[1170] | 77 | // When
|
---|
| 78 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 79 | // Then
|
---|
| 80 | assertThat(patternContained).isTrue();
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | @Test
|
---|
| 84 | public void starts_with_pattern_contains_event_and_ends_with_pattern_negative() {
|
---|
| 85 | // Given
|
---|
| 86 | String spec = "UserSession {" +
|
---|
| 87 | " Sequence seq1 {" +
|
---|
| 88 | " Selection sel1 {" +
|
---|
| 89 | " Sequence seq2 {" +
|
---|
| 90 | " TextInput target4 {}" +
|
---|
[1205] | 91 | " MouseClick target3 {}" +
|
---|
[1170] | 92 | " }" +
|
---|
| 93 | " }" +
|
---|
| 94 | " Selection sel1 {" +
|
---|
| 95 | " Sequence seq3 {" +
|
---|
| 96 | " TextInput target4 {}" +
|
---|
| 97 | " EventTask target2 {}" +
|
---|
| 98 | " }" +
|
---|
| 99 | " }" +
|
---|
[1205] | 100 | " EventTask target2 {}" +
|
---|
| 101 | " TextInput target1 {}" +
|
---|
| 102 | " Selection sel2 {" +
|
---|
| 103 | " Sequence seq5 {" +
|
---|
| 104 | " TextInput target4 {}" +
|
---|
| 105 | " MouseClick target3 {}" +
|
---|
| 106 | " }" +
|
---|
[1170] | 107 | " }" +
|
---|
[1205] | 108 | " Selection sel2 {" +
|
---|
| 109 | " Sequence seq6 {" +
|
---|
| 110 | " TextInput target4 {}" +
|
---|
| 111 | " EventTask target2 {}" +
|
---|
| 112 | " }" +
|
---|
[1170] | 113 | " }" +
|
---|
| 114 | " }" +
|
---|
| 115 | "}";
|
---|
| 116 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 117 | InteractionPattern startsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 118 | InteractionPattern endsWithPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
| 119 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).startsWithPattern(startsWithPattern).containsEvent(SCROLL).endsWithPattern(endsWithPattern).patternFinished().build();
|
---|
[1170] | 120 | // When
|
---|
| 121 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 122 | // Then
|
---|
| 123 | assertThat(patternContained).isFalse();
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | }
|
---|