Search in sources :

Example 16 with CreateQuestionGroupParameters

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

the class PersonnelTest method createUserWithQuestionGroup.

//http://mifosforge.jira.com/browse/MIFOSTEST-670
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void createUserWithQuestionGroup() throws Exception {
    //Given
    createQuestions();
    //When
    Map<String, List<String>> sectionQuestions = new HashMap<String, List<String>>();
    List<String> questions = new ArrayList<String>();
    questions.add("user question 1");
    sectionQuestions.put("Sec 1", questions);
    questions = new ArrayList<String>();
    questions.add("user question 2");
    questions.add("user question 3");
    sectionQuestions.put("Sec 2", questions);
    CreateQuestionGroupParameters createQuestionGroupParameters = new CreateQuestionGroupParameters();
    createQuestionGroupParameters.setAnswerEditable(true);
    createQuestionGroupParameters.setAppliesTo("Create Personnel");
    createQuestionGroupParameters.setTitle("Create Personnel QG1");
    createQuestionGroupParameters.setExistingQuestions(sectionQuestions);
    questionGroupTestHelper.createQuestionGroup(createQuestionGroupParameters);
    sectionQuestions = new HashMap<String, List<String>>();
    questions = new ArrayList<String>();
    questions.add("user question 4");
    sectionQuestions.put("Sec 3", questions);
    createQuestionGroupParameters = new CreateQuestionGroupParameters();
    createQuestionGroupParameters.setAnswerEditable(true);
    createQuestionGroupParameters.setAppliesTo("Create Personnel");
    createQuestionGroupParameters.setTitle("Create Personnel QG2");
    createQuestionGroupParameters.setExistingQuestions(sectionQuestions);
    questionGroupTestHelper.createQuestionGroup(createQuestionGroupParameters);
    AdminPage adminPage = navigationHelper.navigateToAdminPage();
    CreateUserParameters userParameters = adminPage.getAdminUserParameters();
    ChooseOfficePage createUserPage = adminPage.navigateToCreateUserPage();
    createUserPage.verifyPage();
    CreateUserEnterDataPage userEnterDataPage = createUserPage.selectOffice("MyOfficeDHMFT");
    QuestionResponsePage questionResponsePage = userEnterDataPage.submitAndNavigateToQuestionResponsePage(userParameters);
    questionResponsePage.verifyPage();
    QuestionResponseParameters responseParameters = new QuestionResponseParameters();
    responseParameters.addSingleSelectAnswer("questionGroups[0].sectionDetails[0].questions[0].value", "yes");
    responseParameters.addTextAnswer("questionGroups[0].sectionDetails[1].questions[1].value", "text1");
    questionResponsePage.populateAnswers(responseParameters);
    CreateUserPreviewDataPage createUserPreviewDataPage = questionResponsePage.continueAndNavigateToCreateUserPreviewPage();
    questionResponsePage = createUserPreviewDataPage.navigateToEditAdditionalInformation();
    questionResponsePage.populateTextAnswer("questionGroups[0].sectionDetails[1].questions[1].value", "text2");
    createUserPreviewDataPage = questionResponsePage.continueAndNavigateToCreateUserPreviewPage();
    CreateUserConfirmationPage userConfirmationPage = createUserPreviewDataPage.submit();
    QuestionnairePage questionnairePage = userConfirmationPage.navigateToUserViewDetailsPage().navigateToQuestionnairePage();
    //Then
    questionnairePage.verifyRadioGroup("details[0].sectionDetails[0].questions[0].value", "yes", true);
    questionnairePage.verifyRadioGroup("details[0].sectionDetails[1].questions[0].value", "good", false);
    questionnairePage.verifyField("details[0].sectionDetails[1].questions[1].value", "text2");
    //When
    questionnairePage.typeText("details[0].sectionDetails[1].questions[1].value", "text3");
    questionnairePage.submitAndNavigateToPersonnalDetailsPage();
    List<String> questionToAdd = new ArrayList<String>();
    questionToAdd.add("user question 5");
    questionToAdd.add("user question 6");
    List<String> questionToDesactivate = new ArrayList<String>();
    questionToDesactivate.add("user question 1");
    questionToDesactivate.add("user question 2");
    questionToDesactivate.add("user question 3");
    createQuestionGroupParameters = new CreateQuestionGroupParameters();
    for (String question : questionToAdd) {
        createQuestionGroupParameters.addExistingQuestion("Sec 1", question);
    }
    questionGroupTestHelper.addQuestionsToQuestionGroup("Create Personnel QG1", createQuestionGroupParameters.getExistingQuestions());
    for (String question : questionToDesactivate) {
        questionGroupTestHelper.markQuestionAsInactive(question);
    }
    questionGroupTestHelper.markQuestionGroupAsInactive("Create Personnel QG2");
    adminPage = navigationHelper.navigateToAdminPage();
    userParameters = adminPage.getAdminUserParameters();
    createUserPage = adminPage.navigateToCreateUserPage();
    createUserPage.verifyPage();
    userEnterDataPage = createUserPage.selectOffice("MyOfficeDHMFT");
    questionResponsePage = userEnterDataPage.submitAndNavigateToQuestionResponsePage(userParameters);
    questionResponsePage.verifyPage();
    //Then
    questionResponsePage.verifyQuestionsDoesnotappear(questionToDesactivate.toArray(new String[questionToDesactivate.size()]));
    questionResponsePage.verifyQuestionsExists(questionToAdd.toArray(new String[questionToAdd.size()]));
    questionResponsePage.verifySectionDoesnotappear("Sec 2");
    questionGroupTestHelper.markQuestionGroupAsInactive("Create Personnel QG1");
}
Also used : AdminPage(org.mifos.test.acceptance.framework.admin.AdminPage) CreateQuestionGroupParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupParameters) HashMap(java.util.HashMap) QuestionResponsePage(org.mifos.test.acceptance.framework.questionnaire.QuestionResponsePage) CreateUserEnterDataPage(org.mifos.test.acceptance.framework.user.CreateUserEnterDataPage) QuestionnairePage(org.mifos.test.acceptance.framework.questionnaire.QuestionnairePage) ArrayList(java.util.ArrayList) CreateUserConfirmationPage(org.mifos.test.acceptance.framework.user.CreateUserConfirmationPage) ChooseOfficePage(org.mifos.test.acceptance.framework.office.ChooseOfficePage) QuestionResponseParameters(org.mifos.test.acceptance.framework.loan.QuestionResponseParameters) CreateUserPreviewDataPage(org.mifos.test.acceptance.framework.user.CreateUserPreviewDataPage) CreateUserParameters(org.mifos.test.acceptance.framework.user.CreateUserParameters) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with CreateQuestionGroupParameters

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

the class QuestionGroupSavingsAccountTest method setQuestionGroup.

private void setQuestionGroup() {
    String questionGroupName = "QGForCreateSavingsAccount";
    questionGroupTestHelper.markQuestionGroupAsActive(questionGroupName);
    CreateQuestionGroupParameters createQuestionGroupParameters = questionGroupTestHelper.getCreateQuestionGroupParameters(questionGroupName + "2", asList("Number", "SingleSelect", "FreeText", "question 1"), "Create Savings", "Sec 1");
    createQuestionGroupParameters.addExistingQuestion("Sec 2", "NumberBetween5And10");
    createQuestionGroupParameters.addExistingQuestion("Sec 2", "MultiSelect");
    questionGroupTestHelper.createQuestionGroup(createQuestionGroupParameters);
    Map<String, List<String>> sectionQuestions = new HashMap<String, List<String>>();
    List<String> questions = new ArrayList<String>();
    questions.add("Date");
    questions.add("MultiSelect");
    questions.add("Number");
    questions.add("NumberBetween5And10");
    sectionQuestions.put("Sec 1", questions);
    questions = new ArrayList<String>();
    questions.add("SingleSelect");
    questions.add("FreeText");
    sectionQuestions.put("Sec 2", questions);
    questionGroupTestHelper.addQuestionsToQuestionGroup(questionGroupName, sectionQuestions);
}
Also used : CreateQuestionGroupParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupParameters) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List)

Example 18 with CreateQuestionGroupParameters

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

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

the class QuestionGroupTest method testMissingMandatoryInputs.

private void testMissingMandatoryInputs(CreateQuestionGroupPage createQuestionGroupPage) {
    CreateQuestionGroupParameters parameters = new CreateQuestionGroupParameters();
    createQuestionGroupPage.submit(parameters);
    assertTextFoundOnPage(TITLE_MISSING);
    assertTextFoundOnPage(APPLIES_TO_MISSING);
    assertTextFoundOnPage(SECTION_MISSING);
    createQuestionGroupPage.addEmptySection("Empty Section");
    for (String section : parameters.getExistingQuestions().keySet()) {
        createQuestionGroupPage.addExistingQuestion(section, parameters.getExistingQuestions().get(section));
    }
    assertTextFoundOnPage(QUESTION_MISSING);
}
Also used : CreateQuestionGroupParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupParameters)

Example 20 with CreateQuestionGroupParameters

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

the class QuestionGroupTest method attachingQuestionGroupToMultipleFlowsTest.

/**
     * Attaching a Question Group to Multiple flows
     * http://mifosforge.jira.com/browse/MIFOSTEST-701
     *
     * @throws Exception
     */
@Test(enabled = true)
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void attachingQuestionGroupToMultipleFlowsTest() throws Exception {
    String newClient = "Joe701 Doe701";
    questionGroupTestHelper.markQuestionGroupAsInactive("CreateOffice");
    createClient("Joe701", "Doe701");
    //When
    testValidationAddQuestionGroup();
    Map<String, List<String>> sectionQuestions = new HashMap<String, List<String>>();
    List<String> questions = new ArrayList<String>();
    questions.add("Date");
    questions.add("Number");
    questions.add("Text");
    sectionQuestions.put("Sec Test", questions);
    CreateQuestionGroupParameters createQuestionGroupParameters = new CreateQuestionGroupParameters();
    createQuestionGroupParameters.setAnswerEditable(true);
    String testQuestionGroup = "TestQuestionGroup";
    createQuestionGroupParameters.setTitle(testQuestionGroup);
    createQuestionGroupParameters.setAppliesTo("View Client");
    createQuestionGroupParameters.setAppliesTo("Close Client");
    createQuestionGroupParameters.setExistingQuestions(sectionQuestions);
    try {
        questionGroupTestHelper.createQuestionGroup(createQuestionGroupParameters);
        Map<String, String> answers = new HashMap<String, String>();
        answers.put("Text", "Test - Text");
        answers.put("Number", "2");
        answers.put("Date", "11/11/2009");
        ClientViewDetailsPage clientViewDetailsPage = questionGroupTestHelper.attachQuestionGroup(newClient, testQuestionGroup, asList("Sec Test"), answers);
        CustomerChangeStatusPage customerChangeStatusPage = clientViewDetailsPage.navigateToCustomerChangeStatusPage();
        EditCustomerStatusParameters customerStatusParameters = new EditCustomerStatusParameters();
        customerStatusParameters.setNote("TEST");
        customerStatusParameters.setClientStatus(ClientStatus.CLOSED);
        customerStatusParameters.setClientCloseReason(ClientCloseReason.TRANSFERRED);
        QuestionResponsePage questionResponsePage = customerChangeStatusPage.changeStatusAndNavigateToQuestionResponsePage(customerStatusParameters);
        //Then
        questionResponsePage.verifyQuestionsExists(questions.toArray(new String[questions.size()]));
        //When
        clientViewDetailsPage = questionResponsePage.cancel();
        ViewQuestionResponseDetailPage viewQuestionResponseDetailPage = clientViewDetailsPage.navigateToViewAdditionalInformationPage();
        //Then
        viewQuestionResponseDetailPage.verifyQuestionsDoesnotappear(questions.toArray(new String[questions.size()]));
        clientViewDetailsPage = viewQuestionResponseDetailPage.navigateToClientViewDetailsPage();
        answers = new HashMap<String, String>();
        answers.put("Text", "Test - Text - Edit");
        answers.put("Number", "22");
        questionGroupInstancesOfClient = clientViewDetailsPage.getQuestionGroupInstances();
        questionGroupTestHelper.editResponses(clientViewDetailsPage, latestInstanceId(questionGroupInstancesOfClient), answers);
        // extension MIFOS-5821
        CreateLoanAccountSearchParameters searchParameters = new CreateLoanAccountSearchParameters();
        searchParameters.setSearchString("Client - Mary Monthly");
        searchParameters.setLoanProduct("MonthlyClientFlatLoanThirdFridayOfMonth");
        loanTestHelper.createDefaultLoanAccount(searchParameters);
    } finally {
        questionGroupTestHelper.markQuestionGroupAsInactive(testQuestionGroup);
        questionGroupTestHelper.markQuestionGroupAsInactive("CreateOffice");
    }
}
Also used : CreateLoanAccountSearchParameters(org.mifos.test.acceptance.framework.loan.CreateLoanAccountSearchParameters) ViewQuestionResponseDetailPage(org.mifos.test.acceptance.framework.questionnaire.ViewQuestionResponseDetailPage) CreateQuestionGroupParameters(org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupParameters) HashMap(java.util.HashMap) QuestionResponsePage(org.mifos.test.acceptance.framework.questionnaire.QuestionResponsePage) ArrayList(java.util.ArrayList) ClientViewDetailsPage(org.mifos.test.acceptance.framework.client.ClientViewDetailsPage) EditCustomerStatusParameters(org.mifos.test.acceptance.framework.group.EditCustomerStatusParameters) List(java.util.List) ArrayList(java.util.ArrayList) CustomerChangeStatusPage(org.mifos.test.acceptance.framework.customer.CustomerChangeStatusPage) Test(org.testng.annotations.Test)

Aggregations

CreateQuestionGroupParameters (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupParameters)22 ArrayList (java.util.ArrayList)9 Test (org.testng.annotations.Test)8 AdminPage (org.mifos.test.acceptance.framework.admin.AdminPage)7 HashMap (java.util.HashMap)6 List (java.util.List)6 CreateQuestionGroupPage (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionGroupPage)6 QuestionResponsePage (org.mifos.test.acceptance.framework.questionnaire.QuestionResponsePage)5 QuestionResponseParameters (org.mifos.test.acceptance.framework.loan.QuestionResponseParameters)4 CreateQuestionPage (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionPage)4 CreateQuestionParameters (org.mifos.test.acceptance.framework.questionnaire.CreateQuestionParameters)4 AttachQuestionGroupParameters (org.mifos.test.acceptance.framework.questionnaire.AttachQuestionGroupParameters)3 QuestionnairePage (org.mifos.test.acceptance.framework.questionnaire.QuestionnairePage)3 ViewQuestionResponseDetailPage (org.mifos.test.acceptance.framework.questionnaire.ViewQuestionResponseDetailPage)3 Arrays.asList (java.util.Arrays.asList)1 Random (java.util.Random)1 ManageRolePage (org.mifos.test.acceptance.framework.admin.ManageRolePage)1 ViewRolesPage (org.mifos.test.acceptance.framework.admin.ViewRolesPage)1 CenterViewDetailsPage (org.mifos.test.acceptance.framework.center.CenterViewDetailsPage)1 CreateCenterEnterDataPage (org.mifos.test.acceptance.framework.center.CreateCenterEnterDataPage)1