Package org.jsurveylib

Examples of org.jsurveylib.Survey


        assertTrue(survey.isLastPageAndComplete());
    }

    @Test
    public void lastPagesSkipped() throws Exception {
        Survey survey = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\pagefiles\\lastpageskipped.xml")));
        assertEquals(0, survey.getCurrentPageNumber());
        assertEquals(0, survey.getCurrentPageNumberExcludingSkipped());
        assertEquals(2, survey.getTotalPagesExcludingSkipped());
        assertEquals(4, survey.getPages().size());

        survey.goToNextPage();
        assertEquals(1, survey.getCurrentPageNumber());
        assertEquals(1, survey.getCurrentPageNumberExcludingSkipped());
        assertEquals(2, survey.getTotalPagesExcludingSkipped());
        assertEquals(4, survey.getPages().size());

        assertFalse(survey.isNextPageAvailable());
        assertTrue(survey.isLastPageAndComplete());
    }
View Full Code Here


*/
public class MenuTest {

    @Test
    public void testDefault() throws Exception {
        Survey s = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\menufiles\\testdefault.xml")));
        Menu m = s.getMenu();
        assertFalse(m.exists());
        assertFalse(m.hasFirstPage());
        assertFalse(m.hasLastPage());
        assertFalse(m.hasNextPage());
        assertFalse(m.hasOpen());
View Full Code Here

        assertFalse(m.hasSaveAs());
    }

    @Test
    public void useAll() throws Exception {
        Survey s = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\menufiles\\useall.xml")));
        Menu m = s.getMenu();
        assertTrue(m.exists());
        assertTrue(m.hasFirstPage());
        assertTrue(m.hasLastPage());
        assertTrue(m.hasNextPage());
        assertTrue(m.hasOpen());
View Full Code Here

        assertTrue(m.hasSaveAs());
    }

    @Test
    public void justMenu() throws Exception {
        Survey s = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\menufiles\\justmenu.xml")));
        Menu m = s.getMenu();
        assertTrue(m.exists());
        assertFalse(m.hasNextPage());
        assertFalse(m.hasOpen());
        assertFalse(m.hasPreviousPage());
        assertFalse(m.hasSave());
View Full Code Here

*/
public class PopulateDropdownTest {

    @Test
    public void populateDropdown() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatedropdownfiles\\populatedropdown.xml")));
        DropdownQuestion dd = (DropdownQuestion) model.getQuestionByID("dd");
        assertEquals(4, dd.getChoices().size());
        checkChoice(dd, 0, "", "");
        checkChoice(dd, 1, "A", "a");
        checkChoice(dd, 2, "B", "b");
        checkChoice(dd, 3, "C", "c");
View Full Code Here

        checkChoice(dd, 3, "C", "c");
    }

    @Test(expected = Exception.class)
    public void populateDropdownInvalid1() throws Exception {
        new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatedropdownfiles\\populatedropdowninvalid1.xml")));
    }
View Full Code Here

        new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatedropdownfiles\\populatedropdowninvalid1.xml")));
    }

    @Test(expected = Exception.class)
    public void populateDropdownInvalid2() throws Exception {
        new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatedropdownfiles\\populatedropdowninvalid2.xml")));
    }
View Full Code Here

        new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatedropdownfiles\\populatedropdowninvalid2.xml")));
    }

    @Test(expected = Exception.class)
    public void populateDropdownInvalid3() throws Exception {
        new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatedropdownfiles\\populatedropdowninvalid3.xml")));
    }
View Full Code Here

*/
public class SetOnAnswerChangedTest {

    @Test
    public void setOnAnswerChanged() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\setonanswerchangedfiles\\setonanswerchanged.xml")));
        assertTrue(model.getQuestionByID("Y").isEnabled());
        model.setAnswer("X", "yes");
        assertFalse(model.getQuestionByID("Y").isEnabled());

        model.setAnswer("setonanswerchanged", "yes");   //this changes the onAnswerChanged of "Y"
        assertFalse(model.getQuestionByID("Y").isEnabled());    //this stays the same until we call it
        model.setAnswer("X", "no");
        assertTrue(model.getQuestionByID("Y").isEnabled());
    }
View Full Code Here

*/
public class SkipPageTest {

    @Test
    public void skipPage() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\skippagefiles\\skippage.xml")));
        Question p0 = model.getQuestionByID("page0");
        Question p1 = model.getQuestionByID("page1");
        Question p2 = model.getQuestionByID("page2");

        assertEquals(0, model.getCurrentPageNumber());
        assertTrue(model.isNextPageAvailable());
        assertFalse(model.isPreviousPageAvailable());
        assertFalse(model.isLastPageAndComplete());

        p1.setAnswer("yes");    //skip page 1
        p2.setAnswer("yes");    //skip page 2

        assertFalse(model.isNextPageAvailable());
        assertFalse(model.isPreviousPageAvailable());
        assertTrue(model.isLastPageAndComplete());

        p2.setAnswer("no");    //make page 2 visitable

        assertTrue(model.isNextPageAvailable());
        assertFalse(model.isPreviousPageAvailable());
        assertFalse(model.isLastPageAndComplete());

        model.goToNextPage();
        assertEquals(2, model.getCurrentPageNumber());

        assertFalse(model.isNextPageAvailable());
        assertTrue(model.isPreviousPageAvailable());
        assertTrue(model.isLastPageAndComplete());

        p1.setAnswer("no"); //make page 1 visitable

        assertFalse(model.isNextPageAvailable());
        assertTrue(model.isPreviousPageAvailable());
        assertTrue(model.isLastPageAndComplete());

        model.goToPreviousPage();

        assertEquals(1, model.getCurrentPageNumber());
        assertTrue(model.isNextPageAvailable());
        assertTrue(model.isPreviousPageAvailable());
        assertFalse(model.isLastPageAndComplete());

        p0.setAnswer("yes");    //skip page 0

        assertTrue(model.isNextPageAvailable());
        assertFalse(model.isPreviousPageAvailable());
        assertFalse(model.isLastPageAndComplete());
    }
View Full Code Here

TOP

Related Classes of org.jsurveylib.Survey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.