[5] | 1 | package tudelft.mentalhealth.motivatepersisting;
|
---|
| 2 |
|
---|
| 3 | import static org.junit.Assert.assertEquals;
|
---|
| 4 | import static org.junit.Assert.assertTrue;
|
---|
| 5 |
|
---|
| 6 | import java.io.IOException;
|
---|
| 7 | import java.util.Locale;
|
---|
| 8 |
|
---|
| 9 | import org.junit.Test;
|
---|
| 10 |
|
---|
| 11 | public 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 | }
|
---|