Package org.jsurveylib

Examples of org.jsurveylib.Survey


    private boolean enableStateChanged = false;

    @Test
    public void standard() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\enablehandlerfiles\\standard.xml")));
        model.getQuestionByID("X").addEnableListener(this);


        assertFalse(enableStateChanged);
        model.getQuestionByID("Y").setAnswer("yes");
        assertTrue(enableStateChanged);
        assertTrue(model.getQuestionByID("X").isEnabled());
    }
View Full Code Here


        assertTrue(model.getQuestionByID("X").isEnabled());
    }

    @Test
    public void startDisabled() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\enablehandlerfiles\\startdisabled.xml")));
        assertFalse(model.getQuestionByID("X").isEnabled());
    }
View Full Code Here

        assertFalse(model.getQuestionByID("X").isEnabled());
    }

    @Test
    public void twoDependencies() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\enablehandlerfiles\\twodependencies.xml")));
        model.getQuestionByID("Y").addEnableListener(this);

        assertFalse(model.getQuestionByID("Y").isEnabled());
        assertFalse(enableStateChanged);
        model.getQuestionByID("X").setAnswer("yes");
        assertFalse(enableStateChanged);
        model.getQuestionByID("Z").setAnswer("yes");
        assertTrue(enableStateChanged);
        assertTrue(model.getQuestionByID("Y").isEnabled());
    }
View Full Code Here

    }

    @Test
    public void complexExpression() throws Exception {
        //<visibility expression="(multichoice == 'two' OR checkbox != 'checked' OR textfield == 'hi') AND filechooser == 'some/file'"/>
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\enablehandlerfiles\\complexexpression.xml")));

        assertFalse(model.getQuestionByID("withparens").isEnabled());
        model.setAnswer("multichoice", "two");
        model.setAnswer("checkbox", "unchecked");
        model.setAnswer("textfield", "hi");
        model.setAnswer("filechooser", "false");
        assertFalse(model.getQuestionByID("withparens").isEnabled());
        assertTrue(model.getQuestionByID("withoutparens").isEnabled());

        model.setAnswer("filechooser", "some/file");
        assertTrue(model.getQuestionByID("withparens").isEnabled());
        assertTrue(model.getQuestionByID("withoutparens").isEnabled());
    }
View Full Code Here

        assertTrue(model.getQuestionByID("withoutparens").isEnabled());
    }

    @Test
    public void variables() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\enablehandlerfiles\\variables.xml")));
        model.getQuestionByID("variableusage").addEnableListener(this);
        assertFalse(enableStateChanged);
        model.setAnswer("textfield", "4");
        assertTrue(enableStateChanged);
        assertTrue(model.getQuestionByID("variableusage").isEnabled());
    }
View Full Code Here

    private boolean stateChanged = false;

    @Test
    public void defaults() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typeinvisiblefiles\\defaults.xml")));
        m.getQuestionByID("invisible").addAnswerListener(this);
        FreeTextQuestion invisible = (FreeTextQuestion) m.getQuestionByID("invisible");
        assertFalse(invisible.isAnswerable());    //it's invisible so this method returns false
        assertFalse(stateChanged);
        invisible.setAnswer("blah");
        assertTrue(stateChanged);
        assertTrue(invisible.isAnswered());
View Full Code Here

        assertFalse(invisible.isAnswerable());    //it's invisible so this method returns false
    }

    @Test
    public void defaultSet() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typeinvisiblefiles\\defaultset.xml")));
        m.getQuestionByID("invisible").addAnswerListener(this);
        FreeTextQuestion invisible = (FreeTextQuestion) m.getQuestionByID("invisible");
        assertTrue(invisible.isAnswered())//it's invisible so this method returns true
        assertEquals("hah", invisible.getAnswer());
        assertFalse(stateChanged);
        invisible.setAnswer("blah");
        assertTrue(stateChanged);
View Full Code Here

    private String url;

    @Test
    public void cdata() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\labelfiles\\cdata.xml")));
        Label l = (Label) m.getCurrentPage().getSurveyElements().get(0);
        assertEquals("There is a \"visibility script\" on this page that is making a checkbox invisible right now.  To make the checkbox visible, type the magic word into this text field. The magic word is <b>please</b>", l.getText());
    }
View Full Code Here

        assertEquals("There is a \"visibility script\" on this page that is making a checkbox invisible right now.  To make the checkbox visible, type the magic word into this text field. The magic word is <b>please</b>", l.getText());
    }

    @Test
    public void linkClicked() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\labelfiles\\linkclicked.xml")));
        Label l = (Label) m.getCurrentPage().getSurveyElements().get(0);
        l.addLinkListener(this);
        assertNull(url);
        l.linkClicked("blah");
        assertEquals("blah", url);

        assertEquals(0, m.getCurrentPageNumber());
        l.linkClicked("page://1");
        assertEquals("page://1", url);
        assertEquals(1, m.getCurrentPageNumber());
        assertFalse(m.isLastPageAndComplete()); //a mandatory question is not answered

        l.linkClicked("page://0");
        assertEquals("page://0", url);
        assertEquals(0, m.getCurrentPageNumber());

        m.getQuestionByID("pageJump").getLabel().linkClicked("page://1");
        l.linkClicked("page://1");
        assertEquals("page://1", url);
    }
View Full Code Here

        assertEquals("page://1", url);
    }

    @Test(expected = java.lang.IndexOutOfBoundsException.class)
    public void badPageLink() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\labelfiles\\badpagelink.xml")));
        Label l = (Label) m.getCurrentPage().getSurveyElements().get(0);
        l.linkClicked("page://2");
    }
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.