1 | package tudelft.healthpsychology.traumaontologies.answerstate;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 | import static org.mockito.Matchers.any;
|
---|
5 | import static org.mockito.Mockito.mock;
|
---|
6 | import static org.mockito.Mockito.when;
|
---|
7 |
|
---|
8 | import java.util.Arrays;
|
---|
9 | import java.util.Collection;
|
---|
10 | import java.util.List;
|
---|
11 |
|
---|
12 | import org.junit.Before;
|
---|
13 | import org.junit.Test;
|
---|
14 |
|
---|
15 | import tudelft.healthpsychology.traumaontologies.questiontypes.Bool;
|
---|
16 | import tudelft.healthpsychology.traumaontologies.questiontypes.TypedQuestion;
|
---|
17 | import tudelft.utilities.tree.Tree;
|
---|
18 |
|
---|
19 | public 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 | }
|
---|