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);
}
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;
}
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();
}
}
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);
}
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();
}
Aggregations