[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.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;
|
---|
[1151] | 21 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
| 22 |
|
---|
| 23 | import org.junit.Test;
|
---|
| 24 |
|
---|
[1171] | 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;
|
---|
[1171] | 28 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
[1151] | 29 |
|
---|
| 30 | /**
|
---|
| 31 | * <p>
|
---|
| 32 | * TODO comment
|
---|
| 33 | * </p>
|
---|
| 34 | *
|
---|
| 35 | * @author Alexander Deicke
|
---|
| 36 | */
|
---|
| 37 | public class ContainsAndEndsWithEventTest {
|
---|
| 38 |
|
---|
[1171] | 39 | @Test
|
---|
| 40 | public void contains_and_ends_with_event_positive() {
|
---|
[1151] | 41 | // Given
|
---|
[1171] | 42 | String spec = "UserSession {" +
|
---|
| 43 | " Sequence seq1 {" +
|
---|
| 44 | " TextInput t1 {}" +
|
---|
| 45 | " }" +
|
---|
[1151] | 46 | "}";
|
---|
[1171] | 47 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 48 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SEQUENCE).containsEvent(TEXT_INPUT).endsWithEvent(TEXT_INPUT).patternFinished().build();
|
---|
[1151] | 49 | // When
|
---|
| 50 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 51 | // Then
|
---|
| 52 | assertThat(patternContained).isTrue();
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | @Test
|
---|
[1171] | 57 | public void contains_and_ends_with_event_negative() {
|
---|
[1151] | 58 | // Given
|
---|
[1171] | 59 | String spec = "UserSession {" +
|
---|
| 60 | " Iteration it1 {" +
|
---|
| 61 | " Sequence seq1 {" +
|
---|
| 62 | " EventTask t1 {}" +
|
---|
| 63 | " EventTask t2 {}" +
|
---|
[1151] | 64 | " }" +
|
---|
| 65 | " }" +
|
---|
| 66 | "}";
|
---|
[1171] | 67 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1218] | 68 | InteractionPattern pattern = InteractionPatternBuilder.newPattern().rootTask(SELECTION).containsEvent(TEXT_INPUT).endsWithEvent(MOUSE_CLICK).patternFinished().build();
|
---|
[1151] | 69 | // When
|
---|
| 70 | boolean patternContained = pattern.containedIn(taskTree);
|
---|
| 71 | // Then
|
---|
| 72 | assertThat(patternContained).isFalse();
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | }
|
---|