use of org.mifos.test.acceptance.framework.user.CreateUserParameters 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");
}
Aggregations