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