Package org.jsurveylib

Examples of org.jsurveylib.Survey


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

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


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

    @Test
    public void loadXMLAnswersAfter() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\loadxmlanswersafter.xml")));
        model.loadXMLAnswers("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\loadxmlanswersafterresult.xml");
        //every time you answer a question, the populateTemplate adds a new one AFTER what already exists
        assertEquals(10, model.getPages().get(0).getQuestions().size());
        assertEquals("first", model.getPages().get(0).getQuestions().get(0).getAnswer());
        assertEquals("first", model.getPages().get(0).getQuestions().get(1).getAnswer());
        assertEquals("second", model.getPages().get(0).getQuestions().get(2).getAnswer());
        assertEquals("second", model.getPages().get(0).getQuestions().get(3).getAnswer());
        assertEquals("third", model.getPages().get(0).getQuestions().get(4).getAnswer());
        assertEquals("third", model.getPages().get(0).getQuestions().get(5).getAnswer());
        assertEquals("fourth", model.getPages().get(0).getQuestions().get(6).getAnswer());
        assertEquals("fourth", model.getPages().get(0).getQuestions().get(7).getAnswer());
        assertEquals("", model.getPages().get(0).getQuestions().get(8).getAnswer());
        assertEquals("", model.getPages().get(0).getQuestions().get(9).getAnswer());
    }
View Full Code Here

        assertEquals("", model.getPages().get(0).getQuestions().get(9).getAnswer());
    }

    @Test
    public void loadXMLAnswersBefore() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\loadxmlanswersbefore.xml")));
        model.loadXMLAnswers("src\\test\\org\\jsurveylib\\model\\script\\populatetemplatefiles\\loadxmlanswersbeforeresult.xml");
        //every time you answer a question, the populateTemplate adds a new one AFTER what already exists
        assertEquals(10, model.getPages().get(0).getQuestions().size());
        assertEquals("first", model.getPages().get(0).getQuestions().get(9).getAnswer());
        assertEquals("first", model.getPages().get(0).getQuestions().get(8).getAnswer());
        assertEquals("second", model.getPages().get(0).getQuestions().get(7).getAnswer());
        assertEquals("second", model.getPages().get(0).getQuestions().get(6).getAnswer());
        assertEquals("third", model.getPages().get(0).getQuestions().get(5).getAnswer());
        assertEquals("third", model.getPages().get(0).getQuestions().get(4).getAnswer());
        assertEquals("fourth", model.getPages().get(0).getQuestions().get(3).getAnswer());
        assertEquals("fourth", model.getPages().get(0).getQuestions().get(2).getAnswer());
        assertEquals("", model.getPages().get(0).getQuestions().get(1).getAnswer());
        assertEquals("", model.getPages().get(0).getQuestions().get(0).getAnswer());
    }
View Full Code Here

    private Boolean newStatus;
    private String errorMessage;

    @Test
    public void orderOfMessages() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\validationhandlerfiles\\orderofmessages.xml")));
        Question q = m.getQuestionByID("blah");
        q.addValidationListener(this);
        assertFalse(q.isValid());

        assertNull(newStatus);
        assertNull(errorMessage);
View Full Code Here

        assertEquals("", errorMessage);
    }

    @Test
    public void configValidation() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\validationhandlerfiles\\configvalidation.xml")));
        Question q = m.getQuestionByID("textArea");
        q.addValidationListener(this);
        assertFalse(q.isValid());

        q.setAnswer("");
        assertFalse(q.isValid());
View Full Code Here

        assertEquals("", errorMessage);
    }

    @Test
    public void checkOtherQuestion() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\validationhandlerfiles\\checkotherquestion.xml")));
        Question password = m.getQuestionByID("password");
        Question confirm = m.getQuestionByID("confirm");

        assertTrue(confirm.isValid());
        password.setAnswer("secret");
        assertFalse(confirm.isValid());
        assertFalse(m.getCurrentPage().areRequirementsMet());
        confirm.setAnswer("secret");
        assertTrue(confirm.isValid());
        assertTrue(m.getCurrentPage().areRequirementsMet());
    }
View Full Code Here

        assertTrue(m.getCurrentPage().areRequirementsMet());
    }

    @Test
    public void errorMessageExpression() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\validationhandlerfiles\\errormessageexpression.xml")));
        Question password = m.getQuestionByID("password");
        Question confirm = m.getQuestionByID("confirm");
        Question five = m.getQuestionByID("five");

        assertTrue(confirm.isValid());
        assertEquals("", confirm.getCurrentValidationMessage());
        password.setAnswer("secret");
        assertFalse(confirm.isValid());
        assertFalse(m.getCurrentPage().areRequirementsMet());
        assertEquals("You did not type secret", confirm.getCurrentValidationMessage());
        confirm.setAnswer("secret");
        assertTrue(confirm.isValid());
        assertEquals("", confirm.getCurrentValidationMessage());
        assertFalse(five.isValid());
View Full Code Here

    private boolean enChanged = false;
    private boolean valChanged = false;

    @Test
    public void standard() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typedropdownfiles\\standard.xml")));
        m.getQuestionByID("drop").addAnswerListener(this);
        DropdownQuestion drop = (DropdownQuestion) m.getQuestionByID("drop");
        Choice c0 = drop.getChoices().get(0);
        assertEquals("", c0.getId());
        assertEquals("blah", c0.getLabel());

        Choice c1 = drop.getChoices().get(1);
View Full Code Here

        assertTrue(true);
    }

    @Test
    public void dupe() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typedropdownfiles\\dupe.xml")));
        DropdownQuestion orig = (DropdownQuestion) m.getQuestionByID("cb");
        orig.addAnswerListener(this);
        orig.addEnableListener(this);
        orig.addValidationListener(this);
        orig.addVisibilityListener(this);
View Full Code Here

    private boolean enChanged = false;
    private boolean valChanged = false;

    @Test
    public void defaults() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typefilechooserfiles\\defaults.xml")));
        m.getQuestionByID("chooser").addAnswerListener(this);
        FileChooserQuestion chooser = (FileChooserQuestion) m.getQuestionByID("chooser");

        assertEquals(0, chooser.getFileFilters().size());
        assertTrue(chooser.isAllFilesFilterEnabled());
        assertTrue(chooser.isOpenDialog());
        assertFalse(chooser.isSaveDialog());
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.