AllBeneficiaries { public void closeMother(String entityId) { alertRepository.deleteAllAlertsForEntity(entityId); timelineEventRepository.deleteAllTimelineEventsForEntity(entityId); motherRepository.close(entityId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository,
                            AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); Mother findMotherWithOpenStatus(String caseId); Mother findMother(String caseId); Child findChild(String caseId); long ancCount(); long pncCount(); long childCount(); List<Pair<Mother, EligibleCouple>> allANCsWithEC(); List<Pair<Mother, EligibleCouple>> allPNCsWithEC(); Mother findMotherByECCaseId(String ecCaseId); List<Child> findAllChildrenByMotherId(String entityId); List<Child> findAllChildrenByCaseIDs(List<String> caseIds); List<Mother> findAllMothersByCaseIDs(List<String> caseIds); void switchMotherToPNC(String entityId); void closeMother(String entityId); void closeChild(String entityId); void closeAllMothersForEC(String ecId); List<Child> allChildrenWithMotherAndEC(); List<Child> findAllChildrenByECId(String ecId); Mother findMotherWithOpenStatusByECId(String ecId); boolean isPregnant(String ecId); void updateChild(Child child); void updateMother(Mother mother);  }
@Test public void shouldDeleteTimelineEventsAndAlertsWhileClosingMother() throws Exception { allBeneficiaries.closeMother("entity id 1"); verify(alertRepository).deleteAllAlertsForEntity("entity id 1"); verify(timelineEventRepository).deleteAllTimelineEventsForEntity("entity id 1"); }