/* Tests CDR */ @Test public void test_poll_with_ordo_questions() { // GIVEN Poll sond = new Poll(); Question q1 = new Question(); q1.setId(1); q1.setOrderNumber(1); Question q2 = new Question(); q2.setId(2); q2.setOrderNumber(2); List<Question> quests = new ArrayList<Question>(); quests.add(q1); quests.add(q2); // WHEN sond.setQuestions(quests); // THEN assertEquals(sond.getQuestions().get(0).getOrderNumber(), 1); assertEquals(sond.getQuestions().get(1).getOrderNumber(), 2); }
@Test public void test_question_setOrderNumber() { // GIVEN Question q = new Question(); int order = 54; // WHEN q.setOrderNumber(order); // THEN assertEquals(q.getOrderNumber(), order); }
@Test public void test_question_setOrderNumber_negative() { // GIVEN Question q = new Question(); int order = -54; try { // WHEN q.setOrderNumber(order); fail("order number can not be negative or 0"); } catch (IllegalArgumentException exc) { // THEN assertEquals(exc.getMessage(), "order number can not be negative or 0"); } }