[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 |
|
---|
| 17 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.MOUSE_CLICK;
|
---|
| 18 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT;
|
---|
[1152] | 19 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.ITERATION;
|
---|
| 20 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION;
|
---|
| 21 | import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE;
|
---|
[1151] | 22 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 23 |
|
---|
| 24 | import org.junit.Test;
|
---|
| 25 |
|
---|
[1171] | 26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1151] | 27 | import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern;
|
---|
| 28 | import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder;
|
---|
[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
|
---|
[1171] | 41 | public void starts_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 {}" +
|
---|
| 50 | " MouseClick target2 {}" +
|
---|
[1171] | 51 | " }" +
|
---|
| 52 | " }" +
|
---|
| 53 | " Selection sel1 {" +
|
---|
| 54 | " Sequence seq3 {" +
|
---|
[1151] | 55 | " TextInput target4 {}" +
|
---|
[1171] | 56 | " EventTask target2 {}" +
|
---|
[1151] | 57 | " }" +
|
---|
| 58 | " }" +
|
---|
| 59 | " }" +
|
---|
| 60 | "}";
|
---|
[1171] | 61 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1151] | 62 | UsagePatternBuilder patternBuilder = new UsagePatternBuilder();
|
---|
[1171] | 63 | UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
|
---|
[1151] | 64 | UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).endsWith(endsWithPattern).build();
|
---|
| 65 | // When
|
---|
| 66 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 67 | // Then
|
---|
| 68 | assertThat(patternContained).isTrue();
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | @Test
|
---|
[1171] | 72 | public void starts_with_pattern_negative() {
|
---|
[1151] | 73 | // Given
|
---|
[1171] | 74 | String spec = "UserSession {" +
|
---|
| 75 | " Selection sel1 {" +
|
---|
| 76 | " Sequence seq1 {" +
|
---|
| 77 | " EventTask target1 {}" +
|
---|
[1151] | 78 | " EventTask target2 {}" +
|
---|
| 79 | " }" +
|
---|
| 80 | " }" +
|
---|
[1171] | 81 | " Selection sel1 {" +
|
---|
| 82 | " Iteration it1 {" +
|
---|
| 83 | " Sequence seq2 {" +
|
---|
| 84 | " MouseClick target5 {}" +
|
---|
| 85 | " EventTask target4 {}" +
|
---|
| 86 | " EventTask target2 {}" +
|
---|
| 87 | " }" +
|
---|
[1151] | 88 | " }" +
|
---|
| 89 | " }" +
|
---|
[1171] | 90 | " Selection sel1 {" +
|
---|
| 91 | " Sequence seq3 {" +
|
---|
| 92 | " EventTask target5 {}" +
|
---|
[1151] | 93 | " EventTask target6 {}" +
|
---|
| 94 | " }" +
|
---|
| 95 | " }" +
|
---|
| 96 | "}";
|
---|
[1171] | 97 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1151] | 98 | UsagePatternBuilder patternBuilder = new UsagePatternBuilder();
|
---|
[1171] | 99 | UsagePattern endsWithPattern = patternBuilder.concernedNode(ITERATION).startsWith(MOUSE_CLICK).contains(TEXT_INPUT).build();
|
---|
| 100 | UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).endsWith(endsWithPattern).build();
|
---|
[1151] | 101 | // When
|
---|
| 102 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 103 | // Then
|
---|
| 104 | assertThat(patternContained).isFalse();
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | }
|
---|