@Test public void shouldMarkAllActionsAsInactiveWhenPNCIsClosed() { when(allMothers.findByCaseId("entity id 1")) .thenReturn(new Mother("entity id 1", "ec entity id 1", "thayi 1")); service.close(create().build()); verify(actionService).markAllAlertsAsInactive("entity id 1"); }
@Test public void shouldNotCloseECCaseWhenPNCIsClosedAndReasonIsNeitherDeathOrPermanentRelocation() { when(allMothers.findByCaseId("entity id 1")) .thenReturn(new Mother("entity id 1", "ec entity id 1", "thayi 1")); service.close(create().addFormField("closeReason", "other_reason").build()); verifyZeroInteractions(allEligibleCouples); }
@Test public void shouldCloseECCaseAlsoWhenPNCIsClosedAndReasonIsPermanentRelocation() { when(allMothers.findByCaseId("entity id 1")) .thenReturn(new Mother("entity id 1", "ec entity id 1", "thayi 1")); service.close(create().addFormField("closeReason", "permanent_relocation").build()); verify(allEligibleCouples).close("ec entity id 1"); }
@Test public void shouldCloseAMotherWhenPNCIsClosed() { when(allMothers.findByCaseId("entity id 1")) .thenReturn(new Mother("entity id 1", "ec entity id 1", "thayi 1")); service.close(create().build()); verify(allMothers).close("entity id 1"); }
@Test public void shouldUnEnrollAMotherFromScheduleWhenPNCCaseIsClosed() { when(allMothers.findByCaseId("entity id 1")) .thenReturn(new Mother("entity id 1", "ec entity id 1", "thayi 1")); service.close(create().build()); verify(pncSchedulesService).unEnrollFromSchedules("entity id 1"); }
@Test public void shouldNotDoAnythingIfMotherIsNotRegistered() { when(allMothers.findByCaseId("entity id 1")).thenReturn(null); service.close(create().build()); verifyZeroInteractions(pncSchedulesService); verifyZeroInteractions(allEligibleCouples); verifyZeroInteractions(motherReportingService); verifyZeroInteractions(actionService); }
@Test public void shouldDoReportingWhenPNCIsClosed() { when(allMothers.findByCaseId("entity id 1")) .thenReturn(new Mother("entity id 1", "ec entity id 1", "thayi 1")); when(reportFieldsDefinition.get("pnc_close")).thenReturn(asList("some-key")); FormSubmission submission = create().withFormName("pnc_close").addFormField("some-key", "some-value").build(); service.close(submission); verify(motherReportingService).closePNC(new SafeMap(mapOf("some-key", "some-value"))); }