Search in sources :

Example 21 with CreateQuestionParameters

use of org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters in project head by mifos.

the class ClientTest method createQuestions.

private void createQuestions() {
    List<CreateQuestionParameters> questions = new ArrayList<CreateQuestionParameters>();
    CreateQuestionParameters q1 = new CreateQuestionParameters();
    q1.setType(CreateQuestionParameters.TYPE_SINGLE_SELECT);
    q1.setText("q1");
    q1.setChoicesFromStrings(Arrays.asList(new String[] { "yes", "no" }));
    questions.add(q1);
    CreateQuestionParameters q2 = new CreateQuestionParameters();
    q2.setType(CreateQuestionParameters.TYPE_SINGLE_SELECT);
    q2.setText("q2");
    q2.setChoicesFromStrings(Arrays.asList(new String[] { "good", "bad", "average" }));
    questions.add(q2);
    CreateQuestionParameters q3 = new CreateQuestionParameters();
    q3.setType(CreateQuestionParameters.TYPE_FREE_TEXT);
    q3.setText("q3");
    questions.add(q3);
    CreateQuestionParameters q4 = new CreateQuestionParameters();
    q4.setType(CreateQuestionParameters.TYPE_DATE);
    q4.setText("q4");
    questions.add(q4);
    CreateQuestionParameters q5 = new CreateQuestionParameters();
    q5.setType(CreateQuestionParameters.TYPE_FREE_TEXT);
    q5.setText("q5");
    questions.add(q5);
    CreateQuestionParameters q6 = new CreateQuestionParameters();
    q6.setType(CreateQuestionParameters.TYPE_NUMBER);
    q6.setText("q6");
    q6.setNumericMax(10);
    q6.setNumericMin(0);
    questions.add(q6);
    questionGroupTestHelper.createQuestions(questions);
}
Also used : CreateQuestionParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters) ArrayList(java.util.ArrayList)

Example 22 with CreateQuestionParameters

use of org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters in project head by mifos.

the class QuestionGroupHelper method getCreateQuestionParams.

private CreateQuestionParameters getCreateQuestionParams(String title, String type, List<String> choices, List<List<String>> tags) {
    CreateQuestionParameters parameters = new CreateQuestionParameters();
    parameters.setText(title);
    parameters.setType(type);
    List<Choice> choiceList = new ArrayList<Choice>();
    for (int i = 0; i < choices.size(); i++) {
        choiceList.add(createNewChoice(choices.get(i), tags.get(i)));
    }
    parameters.setChoices(choiceList);
    return parameters;
}
Also used : CreateQuestionParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters) Choice(org.mifos.test.acceptance.framework.questionnaire.Choice) ArrayList(java.util.ArrayList)

Example 23 with CreateQuestionParameters

use of org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters in project head by mifos.

the class QuestionGroupTest method createAndEditQuestionsTest.

/**
     * Creating and editing Questions
     * http://mifosforge.jira.com/browse/MIFOSTEST-700
     *
     * @throws Exception
     */
@Test(enabled = true)
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void createAndEditQuestionsTest() throws Exception {
    //When
    testValidationAddQuestion();
    CreateQuestionPage createQuestionPage = questionGroupTestHelper.navigateToCreateQuestionPage();
    CreateQuestionParameters createQuestionParameters = new CreateQuestionParameters();
    createQuestionParameters.setText("TextQuestionTest");
    createQuestionParameters.setType(CreateQuestionParameters.TYPE_FREE_TEXT);
    createQuestionPage.addQuestion(createQuestionParameters);
    createQuestionParameters.setText("DateQuestionTest");
    createQuestionParameters.setType(CreateQuestionParameters.TYPE_DATE);
    createQuestionPage.addQuestion(createQuestionParameters);
    createQuestionParameters.setText("NumberQuestionTest");
    createQuestionParameters.setType(CreateQuestionParameters.TYPE_NUMBER);
    createQuestionParameters.setNumericMin(1);
    createQuestionParameters.setNumericMax(10);
    createQuestionPage.addQuestion(createQuestionParameters);
    createQuestionParameters.setText("MultiSelectQuestionTest");
    createQuestionParameters.setType(CreateQuestionParameters.TYPE_MULTI_SELECT);
    List<Choice> choices = new ArrayList<Choice>();
    Choice c = new Choice("choice 1", EMPTY_LIST);
    choices.add(c);
    c = new Choice("choice 2", EMPTY_LIST);
    choices.add(c);
    c = new Choice("choice 3", EMPTY_LIST);
    choices.add(c);
    createQuestionParameters.setChoices(choices);
    createQuestionPage.addQuestion(createQuestionParameters);
    createQuestionParameters.setText("SingleSelectQuestionTest");
    createQuestionParameters.setType(CreateQuestionParameters.TYPE_SINGLE_SELECT);
    createQuestionParameters.setChoices(choices);
    createQuestionPage.addQuestion(createQuestionParameters);
    createQuestionParameters.setText("SmartSelectQuestionTest");
    createQuestionParameters.setChoices(choices);
    createQuestionParameters.setType(CreateQuestionParameters.TYPE_SMART_SELECT);
    createQuestionPage.addQuestion(createQuestionParameters);
    AdminPage adminPage = createQuestionPage.submitQuestions();
    ViewAllQuestionsPage viewAllQuestionsPage = adminPage.navigateToViewAllQuestions();
    //Then
    viewAllQuestionsPage.verifyQuestions(QUESTIONS.keySet());
    //When
    c = new Choice("answerChoice1", EMPTY_LIST);
    choices.add(c);
    c = new Choice("answerChoice3", EMPTY_LIST);
    choices.add(c);
    for (String question : QUESTIONS.keySet()) {
        QuestionDetailPage questionDetailPage = viewAllQuestionsPage.navigateToQuestionDetail(question);
        EditQuestionPage editQuestionPage = questionDetailPage.navigateToEditQuestionPage();
        createQuestionParameters.setText("");
        editQuestionPage.tryUpdate(createQuestionParameters);
        //Then
        editQuestionPage.verifyTextPresent("Please specify the question", "No text <Please specify the question> present on the page");
        questionDetailPage = editQuestionPage.cancelEdit();
        //When
        editQuestionPage = questionDetailPage.navigateToEditQuestionPage();
        for (String characters : charactersList) {
            editQuestionPage.setQuestionName(characters);
            editQuestionPage.verifyQuestionName(characters);
        }
        if ("NumberQuestionTest".equals(question)) {
            editQuestionPage.setNumberQuestion(noNumber, noNumber);
            editQuestionPage.verifyNumberQuestion("", "");
            editQuestionPage.setNumberQuestion("", "");
        } else if ("MultiSelectQuestionTest".equals(question) || "SingleSelectQuestionTest".equals(question)) {
            editQuestionPage.addAnswerChoices(asList("answerChoice1", "answerChoice2", "answerChoice3"));
            editQuestionPage.removeAnswerChoice("4");
        } else if ("SmartSelectQuestionTest".equals(question)) {
            editQuestionPage.addSmartAnswerChoices(asList("answerChoice1", "answerChoice2", "answerChoice3"));
            editQuestionPage.removeAnswerChoice("4");
        }
        editQuestionPage.setQuestionName(question + "Edit");
        questionDetailPage = editQuestionPage.deactivate();
        //Then
        questionDetailPage.verifyQuestionTitle(question + "Edit");
        if ("MultiSelectQuestionTest".equals(question) || "SingleSelectQuestionTest".equals(question) || "SmartSelectQuestionTest".equals(question)) {
            questionDetailPage.assertForChoices(QUESTIONS.get(question), choices);
        }
        viewAllQuestionsPage = questionDetailPage.navigateToViewAllQuestionsPage();
    }
}
Also used : CreateQuestionParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters) Choice(org.mifos.test.acceptance.framework.questionnaire.Choice) AdminPage(org.mifos.test.acceptance.framework.admin.AdminPage) ArrayList(java.util.ArrayList) QuestionDetailPage(org.mifos.test.acceptance.framework.questionnaire.QuestionDetailPage) CreateQuestionPage(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionPage) EditQuestionPage(org.mifos.test.acceptance.framework.questionnaire.EditQuestionPage) ViewAllQuestionsPage(org.mifos.test.acceptance.framework.questionnaire.ViewAllQuestionsPage) Test(org.testng.annotations.Test)

Example 24 with CreateQuestionParameters

use of org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters in project head by mifos.

the class QuestionGroupTest method testCreateQuestionGroup.

private void testCreateQuestionGroup(CreateQuestionGroupPage createQuestionGroupPage, String title, String appliesTo, boolean isAnswerEditable, String sectionName, List<String> questionsToSelect, List<String> questionsNotToSelect, String questionToAdd) {
    CreateQuestionGroupParameters parameters = new CreateQuestionGroupParameters();
    parameters.setTitle(title);
    parameters.setAppliesTo(appliesTo);
    parameters.setAnswerEditable(isAnswerEditable);
    for (String question : questionsToSelect) {
        parameters.addExistingQuestion(sectionName, question);
    }
    for (String section : parameters.getExistingQuestions().keySet()) {
        createQuestionGroupPage.addExistingQuestion(section, parameters.getExistingQuestions().get(section));
    }
    createQuestionGroupPage.markEveryOtherQuestionsMandatory(questionsToSelect);
    assertTrue(createQuestionGroupPage.getAvailableQuestions().containsAll(questionsNotToSelect));
    CreateQuestionParameters createQuestionParameters = new CreateQuestionParameters();
    createQuestionParameters.setType("Free Text");
    createQuestionParameters.setText(questionToAdd);
    createQuestionGroupPage.setSection(SECTION_MISC);
    if (questionToAdd != null) {
        createQuestionGroupPage.addNewQuestion(createQuestionParameters);
    }
    createQuestionGroupPage.submit(parameters);
    assertPage(AdminPage.PAGE_ID);
}
Also used : CreateQuestionParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters) CreateQuestionGroupParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupParameters)

Example 25 with CreateQuestionParameters

use of org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters in project head by mifos.

the class QuestionGroupTest method createQuestions.

private AdminPage createQuestions(String... qTitles) {
    CreateQuestionPage createQuestionPage = getAdminPage().navigateToCreateQuestionPage();
    CreateQuestionParameters parameters = new CreateQuestionParameters();
    for (String qTitle : qTitles) {
        parameters.setText(qTitle);
        parameters.setType("Free Text");
        createQuestionPage.addQuestion(parameters);
    }
    return createQuestionPage.submitQuestions().verifyPage();
}
Also used : CreateQuestionParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters) CreateQuestionPage(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionPage)

Aggregations

CreateQuestionParameters (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters)26 ArrayList (java.util.ArrayList)13 QuestionResponseParameters (org.mifos.test.acceptance.framework.loan.QuestionResponseParameters)7 Test (org.testng.annotations.Test)7 QuestionResponsePage (org.mifos.test.acceptance.framework.questionnaire.QuestionResponsePage)6 HashMap (java.util.HashMap)5 CreateQuestionGroupParameters (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupParameters)4 CreateQuestionPage (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionPage)4 AdminPage (org.mifos.test.acceptance.framework.admin.AdminPage)3 CreateLoanAccountSearchParameters (org.mifos.test.acceptance.framework.loan.CreateLoanAccountSearchParameters)3 LoanAccountPage (org.mifos.test.acceptance.framework.loan.LoanAccountPage)3 QuestionnairePage (org.mifos.test.acceptance.framework.questionnaire.QuestionnairePage)3 ViewQuestionResponseDetailPage (org.mifos.test.acceptance.framework.questionnaire.ViewQuestionResponseDetailPage)3 Choice (org.mifos.test.acceptance.framework.questionnaire.Choice)2 QuestionGroupTestHelper (org.mifos.test.acceptance.framework.testhelpers.QuestionGroupTestHelper)2 DateTime (org.joda.time.DateTime)1 AppLauncher (org.mifos.test.acceptance.framework.AppLauncher)1 EditAccountStatusParameters (org.mifos.test.acceptance.framework.account.EditAccountStatusParameters)1 CenterViewDetailsPage (org.mifos.test.acceptance.framework.center.CenterViewDetailsPage)1 CreateCenterEnterDataPage (org.mifos.test.acceptance.framework.center.CreateCenterEnterDataPage)1