Package org.jsurveylib

Examples of org.jsurveylib.Survey


    private int lastPageInserted;
    private int lastRowInserted;

    @Test
    public void answerof() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\answeroffiles\\answerof.xml")));
        answerOfTest(model);
    }
View Full Code Here


        answerOfTest(model);
    }

    @Test
    public void answerOfReset() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\answeroffiles\\answerof.xml")));
        model.reset();
        answerOfTest(model);
    }
View Full Code Here

    private int lastPageInserted;
    private int lastRowInserted;

    @Test
    public void visible() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\visible.xml")));
        visibleTest(model);
    }
View Full Code Here

        visibleTest(model);
    }

    @Test
    public void visibleReset() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\visible.xml")));
        visibleTest(model);
        model.reset();
        visibleTest(model);
    }
View Full Code Here

        assertEquals(2, lastRowInserted);
    }

    @Test
    public void enabled() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\enabled.xml")));
        model.addInsertQuestionListener(this);
        checkQuestionCount(2, model);
        Question y = model.getQuestionByID("Y");
        y.setAnswer("yes");
        Question x = model.getQuestionByID("X");
        assertFalse(x.isEnabled());
        checkQuestionCount(3, model);
        Question x1 = model.getQuestionByID("X1");
        assertFalse(x1.isEnabled());
        assertEquals("setEnabled(\"X1\", false);", x1.getOnAnswerChanged());
        assertEquals(x1, lastQuestionInserted);
        assertEquals(0, lastPageInserted);
        assertEquals(2, lastRowInserted);

        y.setAnswer("no"); //nothing changes
        assertFalse(x.isEnabled());
        assertFalse(x1.isEnabled());
        assertEquals(x1, lastQuestionInserted);
        assertEquals(0, lastPageInserted);
        assertEquals(2, lastRowInserted);

        y.setAnswer("yes");
        checkQuestionCount(4, model);
        Question x2 = model.getQuestionByID("X2");
        assertFalse(x2.isEnabled());
        assertFalse(x1.isEnabled());
        assertFalse(x.isEnabled());

        assertEquals("setEnabled(\"X2\", false);", x2.getOnAnswerChanged());
View Full Code Here

        assertEquals(3, lastRowInserted);
    }

    @Test
    public void valid() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\valid.xml")));
        model.addInsertQuestionListener(this);
        checkQuestionCount(2, model);
        Question y = model.getQuestionByID("Y");
        y.setAnswer("yes");
        Question x = model.getQuestionByID("X");
        assertFalse(x.isValid());
        checkQuestionCount(3, model);
        Question x1 = model.getQuestionByID("X1");
        assertFalse(x1.isValid());
        assertEquals("blah", x1.getCurrentValidationMessage());
        assertEquals("setValid(\"X1\", false, \"blah\");", x1.getOnAnswerChanged());
        assertEquals(x1, lastQuestionInserted);
        assertEquals(0, lastPageInserted);
        assertEquals(2, lastRowInserted);

        y.setAnswer("no"); //nothing changes
        assertFalse(x.isValid());
        assertEquals("blah", x.getCurrentValidationMessage());
        assertFalse(x1.isValid());
        assertEquals("blah", x1.getCurrentValidationMessage());
        assertEquals(x1, lastQuestionInserted);
        assertEquals(0, lastPageInserted);
        assertEquals(2, lastRowInserted);

        y.setAnswer("yes");
        checkQuestionCount(4, model);
        Question x2 = model.getQuestionByID("X2");
        assertFalse(x2.isValid());
        assertEquals("blah", x2.getCurrentValidationMessage());
        assertFalse(x1.isValid());
        assertEquals("blah", x1.getCurrentValidationMessage());
        assertFalse(x.isValid());
View Full Code Here

        assertEquals(3, lastRowInserted);
    }

    @Test
    public void newScript() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\newscript.xml")));
        model.addInsertQuestionListener(this);
        checkQuestionCount(2, model);
        Question y = model.getQuestionByID("Y");
        y.setAnswer("yes");
        Question x = model.getQuestionByID("X");
        assertFalse(x.isVisible());
        checkQuestionCount(3, model);
        Question x1 = model.getQuestionByID("X1");
        assertTrue(x1.isVisible());
        assertEquals("setVisible(\"X1\", true);setEnabled(\"X1\", !X1.equals(\"no\"));", x1.getOnAnswerChanged());
        assertEquals(x1, lastQuestionInserted);
        assertEquals(0, lastPageInserted);
        assertEquals(2, lastRowInserted);

        y.setAnswer("no"); //nothing changes
        assertFalse(x.isVisible());
        assertTrue(x1.isVisible());
        assertEquals(lastQuestionInserted.getId(), x1, lastQuestionInserted);
        assertEquals(0, lastPageInserted);
        assertEquals(2, lastRowInserted);

        assertTrue(x1.isEnabled());
        x1.setAnswer("no");
        assertFalse(x1.isEnabled());

        y.setAnswer("yes");
        checkQuestionCount(4, model);
        Question x2 = model.getQuestionByID("X2");
        assertFalse(x1.isEnabled());
        assertTrue(x2.isVisible());
        assertTrue(x1.isVisible());
        assertFalse(x.isVisible());
View Full Code Here

        assertEquals(3, lastRowInserted);
    }

    @Test
    public void populateTemplateAfter() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\populatetemplateafter.xml")));
        assertEquals(2, model.getPages().get(0).getQuestions().size());
        assertEquals(model.getQuestionByID("X1"), model.getPages().get(0).getQuestions().get(1));

        model.setAnswer("Y", "no");
        assertEquals(3, model.getPages().get(0).getQuestions().size());
        assertEquals(model.getQuestionByID("Y"), model.getPages().get(0).getQuestions().get(0));
        assertEquals(model.getQuestionByID("X2"), model.getPages().get(0).getQuestions().get(1));
        assertEquals(model.getQuestionByID("X1"), model.getPages().get(0).getQuestions().get(2));
    }
View Full Code Here

        assertEquals(model.getQuestionByID("X1"), model.getPages().get(0).getQuestions().get(2));
    }

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

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

    @Test
    public void populateTemplateBefore() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\populatetemplatebefore.xml")));
        assertEquals(2, model.getPages().get(0).getQuestions().size());
        assertEquals(model.getQuestionByID("X1"), model.getPages().get(0).getQuestions().get(0));

        model.setAnswer("Y", "no");
        assertEquals(3, model.getPages().get(0).getQuestions().size());
        assertEquals(model.getQuestionByID("X1"), model.getPages().get(0).getQuestions().get(0));
        assertEquals(model.getQuestionByID("X2"), model.getPages().get(0).getQuestions().get(1));
        assertEquals(model.getQuestionByID("Y"), model.getPages().get(0).getQuestions().get(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.