source: MotivateDuringTherapy/src/test/java/tudelft/mentalhealth/motivatepersisting/MotivationalAnswerTest.java

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

Intermediate update

File size: 2.2 KB
Line 
1package tudelft.mentalhealth.motivatepersisting;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertTrue;
5
6import java.io.IOException;
7import java.util.Locale;
8
9import org.junit.Test;
10
11public class MotivationalAnswerTest {
12 private final static Locale NL = new Locale("nl", "NL");
13
14 @Test
15 public void smokeTest() throws IOException {
16 new MotivationalAnswer(new Situation(PclTrend.DROPPING, Trust.MEDIUM),
17 NL);
18 }
19
20 @Test
21 public void adviceTest() throws IOException {
22 MotivationalAnswer answer = new MotivationalAnswer(
23 new Situation(PclTrend.DROPPING, Trust.MEDIUM), NL);
24 // this situation requires 3.42 = 3 answers at least.
25 assertEquals(3, answer.getStatements().size());
26 // one Motivation
27 assertTrue(answer.getStatements().stream()
28 .anyMatch(sel -> sel.getCategory() == Category.MOTIVATION));
29 // one NOTEPCL DROPPING
30 assertTrue(answer.getStatements().stream()
31 .anyMatch(sel -> sel.getCategory() == Category.NOTEPCL
32 && sel.getSubcategory() == Subcategory.DROPPING));
33 // one different from the above two.
34 assertTrue(answer.getStatements().stream()
35 .anyMatch(sel -> sel.getCategory() != Category.NOTEPCL
36 && sel.getCategory() != Category.MOTIVATION));
37
38 assertTrue(answer.getText().length() > 30);
39
40 }
41
42 @Test
43 public void advicePaperExampleTest() throws IOException {
44 MotivationalAnswer answer = new MotivationalAnswer(
45 new Situation(PclTrend.RISING, Trust.LOW), NL);
46 // this situation requires 3.89 = 4 answers at least.
47 assertEquals(4, answer.getStatements().size());
48 // one Motivation
49 assertTrue(answer.getStatements().stream()
50 .anyMatch(sel -> sel.getCategory() == Category.MOTIVATION));
51 // one GIVEPERSPECTIVE
52 assertTrue(answer.getStatements().stream().anyMatch(
53 sel -> sel.getCategory() == Category.GIVEPERSPECTIVE));
54 // one NOTEPCL RISING
55 assertTrue(answer.getStatements().stream()
56 .anyMatch(sel -> sel.getCategory() == Category.NOTEPCL
57 && sel.getSubcategory() == Subcategory.RISING));
58 // one different from the above.
59 assertTrue(answer.getStatements().stream().map(sel -> sel.getCategory())
60 .anyMatch(cat -> cat != Category.NOTEPCL
61 && cat != Category.MOTIVATION
62 && cat != Category.TOGETHER));
63
64 assertTrue(answer.getText().length() > 40);
65 }
66
67}
Note: See TracBrowser for help on using the repository browser.