Search in sources :

Example 1 with QuestionGroupDetailMatcher

use of org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher in project head by mifos.

the class QuestionnaireServiceFacadeTest method testGetQuestionGroupById.

@Test
public void testGetQuestionGroupById() throws Exception {
    int questionGroupId = 1;
    List<SectionDetail> sections = asList(getSectionDetailWithQuestionIds("S1", 121), getSectionDetailWithQuestionIds("S2", 122, 123));
    QuestionGroupDetail expectedQuestionGroupDetail = getQuestionGroupDetail(TITLE, "Create", "Client", sections);
    when(questionnaireService.getQuestionGroupById(questionGroupId)).thenReturn(questionGroup);
    when(questionGroup.getActivityId()).thenReturn((short) -1);
    when(rolesPermissionServiceFacade.hasUserAccessForActivity(questionGroup.getActivityId())).thenReturn(true);
    when(questionnaireService.getQuestionGroup(questionGroupId)).thenReturn(expectedQuestionGroupDetail);
    QuestionGroupDetail questionGroupDetail = questionnaireServiceFacade.getQuestionGroupDetail(questionGroupId);
    assertThat(questionGroupDetail, new QuestionGroupDetailMatcher(expectedQuestionGroupDetail));
}
Also used : QuestionGroupDetailMatcher(org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher) Test(org.junit.Test)

Example 2 with QuestionGroupDetailMatcher

use of org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher in project head by mifos.

the class QuestionGroupControllerTest method testEditQuestionGroupSuccess.

@Test
public void testEditQuestionGroupSuccess() throws Exception {
    QuestionGroupForm questionGroup = getQuestionGroupForm("   " + TITLE + " ", "Create.Client", "S1", "S2");
    String result = questionGroupController.defineQuestionGroup(questionGroup, requestContext, false);
    assertThat(result, Is.is("success"));
    QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(TITLE, "Create", "Client", "S1", "S2");
    questionGroupDetail.setActive(false);
    verify(questionnaireServiceFacade).createQuestionGroup(argThat(new QuestionGroupDetailMatcher(questionGroupDetail)));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupDetailMatcher(org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 3 with QuestionGroupDetailMatcher

use of org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher in project head by mifos.

the class QuestionGroupControllerTest method testCreateQuestionGroupSuccess.

@Test
public void testCreateQuestionGroupSuccess() throws Exception {
    QuestionGroupForm questionGroup = getQuestionGroupForm("   " + TITLE + " ", "Create.Client", "S1", "S2");
    String result = questionGroupController.defineQuestionGroup(questionGroup, requestContext, true);
    assertThat(result, Is.is("success"));
    QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(TITLE, "Create", "Client", "S1", "S2");
    questionGroupDetail.setActive(true);
    verify(questionnaireServiceFacade).createActiveQuestionGroup(argThat(new QuestionGroupDetailMatcher(questionGroupDetail)));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupDetailMatcher(org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 QuestionGroupDetailMatcher (org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher)3 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)2 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)2