Search in sources :

Example 1 with Choice

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

the class GroupTest method createGroupInPendingApprovalStateTestWithSurveys.

@Test(singleThreaded = true, groups = { "smoke", "group", "acceptance", "ui", "no_db_unit" })
// one of the dependent methods throws Exception
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void createGroupInPendingApprovalStateTestWithSurveys() throws Exception {
    QuestionGroupTestHelper questionGroupTestHelper = new QuestionGroupTestHelper(selenium);
    String questionGroupTitle = "QG1" + random.nextInt(100);
    String question1 = "Nu_" + random.nextInt(100);
    String question2 = "SS_" + random.nextInt(100);
    List<Choice> choices = asList(new Choice("Choice1", asList("Tag1", "Tag2")), new Choice("Choice2", asList("Tag3", "Tag4")));
    createQuestionGroupForCreateGroup(questionGroupTitle, question1, question2, choices);
    CreateGroupEntryPage groupEntryPage = loginAndNavigateToNewGroupPage();
    CreateGroupSubmitParameters formParameters = getGenericGroupFormParameters();
    QuestionResponsePage questionResponsePage = groupEntryPage.submitNewGroupAndNavigateToQuestionResponsePage(formParameters);
    questionResponsePage.verifyPage();
    questionResponsePage.verifyNumericBoundsValidation("name=questionGroups[0].sectionDetails[0].questions[0].value", "1000", 10, 100, question1);
    questionResponsePage.populateTextAnswer("name=questionGroups[0].sectionDetails[0].questions[0].value", "30");
    questionResponsePage.populateSmartSelect("txtListSearch", getChoiceTags());
    GroupViewDetailsPage groupViewDetailsPage = questionResponsePage.navigateToCreateGroupDetailsPage("Application Pending*");
    ViewQuestionResponseDetailPage responsePage = groupViewDetailsPage.navigateToViewAdditionalInformationPage();
    responsePage.verifyPage();
    responsePage.verifyQuestionPresent(question1, "30");
    responsePage.verifyQuestionPresent(question2, "Choice", "Choice2");
    responsePage.navigateToDetailsPage();
    questionGroupTestHelper.markQuestionGroupAsInactive(questionGroupTitle);
}
Also used : QuestionGroupTestHelper(org.mifos.test.acceptance.framework.testhelpers.QuestionGroupTestHelper) ViewQuestionResponseDetailPage(org.mifos.test.acceptance.framework.questionnaire.ViewQuestionResponseDetailPage) Choice(org.mifos.test.acceptance.framework.questionnaire.Choice) CreateGroupSubmitParameters(org.mifos.test.acceptance.framework.group.CreateGroupEntryPage.CreateGroupSubmitParameters) QuestionResponsePage(org.mifos.test.acceptance.framework.questionnaire.QuestionResponsePage) GroupViewDetailsPage(org.mifos.test.acceptance.framework.group.GroupViewDetailsPage) CreateGroupEntryPage(org.mifos.test.acceptance.framework.group.CreateGroupEntryPage) Test(org.testng.annotations.Test)

Example 2 with Choice

use of org.mifos.test.acceptance.framework.questionnaire.Choice 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 3 with Choice

use of org.mifos.test.acceptance.framework.questionnaire.Choice 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)

Aggregations

Choice (org.mifos.test.acceptance.framework.questionnaire.Choice)3 ArrayList (java.util.ArrayList)2 CreateQuestionParameters (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters)2 Test (org.testng.annotations.Test)2 AdminPage (org.mifos.test.acceptance.framework.admin.AdminPage)1 CreateGroupEntryPage (org.mifos.test.acceptance.framework.group.CreateGroupEntryPage)1 CreateGroupSubmitParameters (org.mifos.test.acceptance.framework.group.CreateGroupEntryPage.CreateGroupSubmitParameters)1 GroupViewDetailsPage (org.mifos.test.acceptance.framework.group.GroupViewDetailsPage)1 CreateQuestionPage (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionPage)1 EditQuestionPage (org.mifos.test.acceptance.framework.questionnaire.EditQuestionPage)1 QuestionDetailPage (org.mifos.test.acceptance.framework.questionnaire.QuestionDetailPage)1 QuestionResponsePage (org.mifos.test.acceptance.framework.questionnaire.QuestionResponsePage)1 ViewAllQuestionsPage (org.mifos.test.acceptance.framework.questionnaire.ViewAllQuestionsPage)1 ViewQuestionResponseDetailPage (org.mifos.test.acceptance.framework.questionnaire.ViewQuestionResponseDetailPage)1 QuestionGroupTestHelper (org.mifos.test.acceptance.framework.testhelpers.QuestionGroupTestHelper)1