Package org.jsurveylib

Examples of org.jsurveylib.Survey


        assertEquals(1, stateChangeCount);
    }

    @Test
    public void visibility() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\dependencyhandler.xml")));
        Question q1 = m.getQuestionByID("Y");
        assertFalse(q1.isVisible());
        m.getQuestionByID("A").setAnswer("no");
        assertFalse(q1.isVisible());
        m.getQuestionByID("A").setAnswer("yes");
        assertTrue(q1.isVisible());
    }
View Full Code Here


        assertTrue(q1.isVisible());
    }

    @Test
    public void hasBeenAnswered() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\hasbeenanswered.xml")));
        Question q1 = m.getQuestionByID("X");
        assertFalse(q1.isAnswered());
        assertTrue(q1.isAnswerable());
        q1.setAnswer("yes");
        assertTrue(q1.isAnswered());
        assertTrue(q1.isAnswerable());

        Question hidden = m.getQuestionByID("Y");   //NOTE: we haven't set an answer on this
        assertFalse(hidden.isAnswerable());
        assertFalse(hidden.isAnswered());
        hidden.setAnswer("yes");
        assertFalse(hidden.isAnswerable());
        assertTrue(hidden.isAnswered());

        Question disabled = m.getQuestionByID("Z");
        assertFalse(disabled.isEnabled());
        assertFalse(disabled.isAnswerable());

        m.getQuestionByID("W").setAnswer("yes");
        assertTrue(disabled.isEnabled());
        assertTrue(disabled.isAnswerable());
    }
View Full Code Here

        assertTrue(disabled.isAnswerable());
    }

    @Test
    public void label() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\label.xml")));
        Question q1 = m.getQuestionByID("Y");
        assertEquals("Y:", q1.getLabel().getText());
        q1.setLabel("Blah");
        assertEquals("Blah", q1.getLabel().getText());
        assertEquals("Answer<b>Yes:</b>", m.getQuestionByID("Z").getLabel().getText());
        assertEquals("Answer<b>Yes:</b>", m.getQuestionByID("X").getLabel().getText());
    }
View Full Code Here

        assertEquals("Answer<b>Yes:</b>", m.getQuestionByID("X").getLabel().getText());
    }

    @Test
    public void id() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\id.xml")));
        Question q1 = m.getQuestionByID("Y");
        assertEquals("Y", q1.getId());
    }
View Full Code Here

        assertEquals("Y", q1.getId());
    }

    @Test
    public void mandatory() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\mandatory.xml")));
        Question q1 = m.getQuestionByID("Y");
        assertTrue(q1.isMandatory());
        q1.setMandatory(false);
        assertFalse(q1.isMandatory());

        Question q2 = m.getQuestionByID("X");
        assertFalse(q2.isMandatory());
        q2.setMandatory(true);
        assertTrue(q2.isMandatory());

        Question q3 = m.getQuestionByID("A");
        assertFalse(q3.isMandatory());
        q3.setMandatory(true);
        assertTrue(q3.isMandatory());
    }
View Full Code Here

        assertTrue(q3.isMandatory());
    }

    @Test
    public void contenttype() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\contenttype.xml")));
        assertTrue(m.getQuestionByID("one") instanceof TextFieldQuestion);
        assertTrue(m.getQuestionByID("two") instanceof RadioButtonsQuestion);
        assertTrue(m.getQuestionByID("three") instanceof FileChooserQuestion);
        assertTrue(m.getQuestionByID("five") instanceof RadioButtonsQuestion);
        assertTrue(m.getQuestionByID("six") instanceof TextAreaQuestion);
    }
View Full Code Here

        new TextFieldQuestion("ENVIRONMENT")//this is a reserved keyword
    }

    @Test
    public void defaultValue() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\defaultvalue.xml")));
        Question five = model.getQuestionByID("five").populateTemplate("blah", null, false, "25-35");
        assertEquals("25-35", five.getAnswer());

        Question two = model.getQuestionByID("two").populateTemplate("blah", null, false, "no");
        assertEquals("no", two.getAnswer());
    }
View Full Code Here

        assertEquals("no", two.getAnswer());
    }

    @Test
    public void onAnswerChanged() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\questionfiles\\onanswerchanged.xml")));
        assertEquals("setVisible(\"blah\", true);", model.getInterpreter().getOnAnswerChanged());
        assertEquals("", model.getQuestionByID("blah").getOnAnswerChanged());
        for (Question q : model.getPages().get(0).getQuestions()) {
            if (!q.getId().equals("blah")) {
                assertEquals("qid=" + q.getId(), "setVisible(\"blah\", false);", q.getOnAnswerChanged());
            }
        }
    }
View Full Code Here

    private boolean visibilityChanged = false;

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


        assertFalse(visibilityChanged);
        model.getQuestionByID("Y").setAnswer("no");
        assertFalse(visibilityChanged);
        assertFalse(model.getQuestionByID("X").isVisible());
        model.getQuestionByID("Y").setAnswer("yes");
        assertTrue(visibilityChanged);
        assertTrue(model.getQuestionByID("X").isVisible());
    }
View Full Code Here

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

    @Test
    public void startInvisible() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\visibilityhandlerfiles\\startinvisible.xml")));
        assertFalse(model.getQuestionByID("X").isVisible());
    }
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.