package tudelft.mentalhealth.motivatepersisting; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Locale; import org.junit.Test; public class MotivationalAnswerTest { private final static Locale NL = new Locale("nl", "NL"); @Test public void smokeTest() throws IOException { new MotivationalAnswer(new Situation(PclTrend.DROPPING, Trust.MEDIUM), NL); } @Test public void adviceTest() throws IOException { MotivationalAnswer answer = new MotivationalAnswer( new Situation(PclTrend.DROPPING, Trust.MEDIUM), NL); // this situation requires 3.42 = 3 answers at least. assertEquals(3, answer.getStatements().size()); // one Motivation assertTrue(answer.getStatements().stream() .anyMatch(sel -> sel.getCategory() == Category.MOTIVATION)); // one NOTEPCL DROPPING assertTrue(answer.getStatements().stream() .anyMatch(sel -> sel.getCategory() == Category.NOTEPCL && sel.getSubcategory() == Subcategory.DROPPING)); // one different from the above two. assertTrue(answer.getStatements().stream() .anyMatch(sel -> sel.getCategory() != Category.NOTEPCL && sel.getCategory() != Category.MOTIVATION)); assertTrue(answer.getText().length() > 30); } @Test public void advicePaperExampleTest() throws IOException { MotivationalAnswer answer = new MotivationalAnswer( new Situation(PclTrend.RISING, Trust.LOW), NL); // this situation requires 3.89 = 4 answers at least. assertEquals(4, answer.getStatements().size()); // one Motivation assertTrue(answer.getStatements().stream() .anyMatch(sel -> sel.getCategory() == Category.MOTIVATION)); // one GIVEPERSPECTIVE assertTrue(answer.getStatements().stream().anyMatch( sel -> sel.getCategory() == Category.GIVEPERSPECTIVE)); // one NOTEPCL RISING assertTrue(answer.getStatements().stream() .anyMatch(sel -> sel.getCategory() == Category.NOTEPCL && sel.getSubcategory() == Subcategory.RISING)); // one different from the above. assertTrue(answer.getStatements().stream().map(sel -> sel.getCategory()) .anyMatch(cat -> cat != Category.NOTEPCL && cat != Category.MOTIVATION && cat != Category.TOGETHER)); assertTrue(answer.getText().length() > 40); } }