Examples of Survey


Examples of org.jsurveylib.Survey

public class ScriptInterpreterTest {

    @Test
    public void overwriteScope() throws Exception {

        ScriptInterpreter vsi = new ScriptInterpreter(new Survey("src\\test\\org\\jsurveylib\\model\\script\\interpreter\\interpreterfiles\\empty.xml"), "", "");
        String expression = "boolean returnTrue() { return true; } returnTrue()";
        assertTrue((Boolean) vsi.eval(expression));
        assertTrue((Boolean) vsi.eval(expression));
    }
View Full Code Here

Examples of org.jsurveylib.Survey

*/
public class GoToPageTest {

    @Test
    public void goToPage() throws Exception {
        Survey survey = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\gotopagefiles\\gotopage.xml")));
        goToPageTest(survey);
    }
View Full Code Here

Examples of org.jsurveylib.Survey

        goToPageTest(survey);
    }

    @Test
    public void goToPageReset() throws Exception {
        Survey survey = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\gotopagefiles\\gotopage.xml")));
        goToPageTest(survey);
        survey.reset();
        goToPageTest(survey);
    }
View Full Code Here

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

Examples of org.jsurveylib.Survey

        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

Examples of org.jsurveylib.Survey

        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

Examples of org.jsurveylib.Survey

    }

    @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

Examples of org.jsurveylib.Survey

        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

Examples of org.jsurveylib.Survey

    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

Examples of org.jsurveylib.Survey

        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
TOP
Copyright © 2018 www.massapi.com. 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.