[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.contains;
|
---|
| 16 |
|
---|
[1218] | 17 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter.TEXT_INPUT;
|
---|
| 18 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SELECTION;
|
---|
| 19 | import static de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter.SEQUENCE;
|
---|
[1151] | 20 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 21 |
|
---|
| 22 | import org.junit.Test;
|
---|
| 23 |
|
---|
[1171] | 24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1205] | 25 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
|
---|
| 26 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
|
---|
[1171] | 27 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
[1151] | 28 |
|
---|
| 29 | /**
|
---|
| 30 | * <p>
|
---|
| 31 | * TODO comment
|
---|
| 32 | * </p>
|
---|
| 33 | *
|
---|
| 34 | * @author Alexander Deicke
|
---|
| 35 | */
|
---|
| 36 | public class ContainsPatternTest {
|
---|
| 37 |
|
---|
[1171] | 38 | @Test
|
---|
| 39 | public void contains_pattern_positive() {
|
---|
[1151] | 40 | // Given
|
---|
[1171] | 41 | String spec = "UserSession {" +
|
---|
| 42 | " Sequence seq1 {" +
|
---|
| 43 | " Selection sel1 {" +
|
---|
| 44 | " TextInput t1 {}" +
|
---|
| 45 | " }" +
|
---|
| 46 | " Selection sel1 {" +
|
---|
| 47 | " MouseClick t2 {}" +
|
---|
| 48 | " }" +
|
---|
[1151] | 49 | " }" +
|
---|
| 50 | "}";
|
---|
[1171] | 51 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 52 | InteractionPattern containsPattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).startsWithEvent(TEXT_INPUT).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
| 53 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).containsPattern(containsPattern).patternFinished().build();
|
---|
[1151] | 54 | // When
|
---|
| 55 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 56 | // Then
|
---|
| 57 | assertThat(patternContained).isTrue();
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | @Test
|
---|
[1171] | 61 | public void contains_pattern_negative() {
|
---|
[1151] | 62 | // Given
|
---|
[1171] | 63 | String spec = "UserSession {" +
|
---|
| 64 | " Iteration it1 {" +
|
---|
| 65 | " Selection sel1 {" +
|
---|
| 66 | " Sequence seq1 {" +
|
---|
| 67 | " EventTask t1 {}" +
|
---|
| 68 | " EventTask t2 {}" +
|
---|
| 69 | " }" +
|
---|
[1151] | 70 | " }" +
|
---|
[1171] | 71 | " Selection sel1 {" +
|
---|
| 72 | " Sequence seq2 {" +
|
---|
| 73 | " EventTask t2 {}" +
|
---|
| 74 | " EventTask t1 {}" +
|
---|
| 75 | " }" +
|
---|
[1151] | 76 | " }" +
|
---|
| 77 | " }" +
|
---|
| 78 | "}";
|
---|
[1171] | 79 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 80 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).containsEvent(TEXT_INPUT).patternFinished().build();
|
---|
[1151] | 81 | // When
|
---|
| 82 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 83 | // Then
|
---|
| 84 | assertThat(patternContained).isFalse();
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | }
|
---|