source: TraumaOntologies/src/test/java/tudelft/healthpsychology/traumaontologies/answerstate/AnswersDepthFirstStateTest.java@ 7

Last change on this file since 7 was 5, checked in by Bart Vastenhouw, 5 years ago

Intermediate update

File size: 1.9 KB
Line 
1package tudelft.healthpsychology.traumaontologies.answerstate;
2
3import static org.junit.Assert.assertEquals;
4import static org.mockito.Matchers.any;
5import static org.mockito.Mockito.mock;
6import static org.mockito.Mockito.when;
7
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.List;
11
12import org.junit.Before;
13import org.junit.Test;
14
15import tudelft.healthpsychology.traumaontologies.questiontypes.Bool;
16import tudelft.healthpsychology.traumaontologies.questiontypes.TypedQuestion;
17import tudelft.utilities.tree.Tree;
18
19public class AnswersDepthFirstStateTest {
20 private final OntologyNode node = mock(OntologyNode.class);
21 private final Bool moreq = mock(Bool.class);
22 private final OntoPropAnswerState firststate = mock(
23 OntoPropAnswerState.class);
24 private final TypedQuestion options = mock(TypedQuestion.class);
25 private final Tree<String, Collection<Property>, OntologyNode> tree = mock(
26 Tree.class);
27
28 @Before
29 public void before() {
30 when(tree.get(any(String.class))).thenReturn(node);
31 }
32
33 @Test
34 public void smokeTest() {
35 List<OntoPropAnswerState> answerstates = Arrays.asList(firststate);
36 TypedQuestion options = mock(TypedQuestion.class);
37 when(firststate.getOptions(tree)).thenReturn(options);
38 new AnswersDepthFirstState("node", answerstates, false, moreq);
39 }
40
41 @Test
42 public void getOptionsTest() {
43 List<OntoPropAnswerState> answerstates = Arrays.asList(firststate);
44 when(firststate.getOptions(tree)).thenReturn(options);
45 AnswersDepthFirstState state = new AnswersDepthFirstState("node",
46 answerstates, false, moreq);
47 assertEquals(options, state.getOptions(tree));
48 }
49
50 @Test
51 public void getOptionsTestFirstStateDone() {
52 List<OntoPropAnswerState> answerstates = Arrays.asList(firststate);
53 when(firststate.getOptions(tree)).thenReturn(null);
54 AnswersDepthFirstState state = new AnswersDepthFirstState("node",
55 answerstates, false, moreq);
56 assertEquals(moreq, state.getOptions(tree));
57 }
58
59}
Note: See TracBrowser for help on using the repository browser.