LocationLoader implements ILocationLoader { @Override public Location loadLocationFor(String bindType, String caseId) { if (bindType.equalsIgnoreCase(CHILD_TYPE)) return loadLocationForChild(caseId); if (bindType.equalsIgnoreCase(MOTHER_TYPE)) return loadLocationForMother(caseId); if (bindType.equalsIgnoreCase(ELIGIBLE_COUPLE_TYPE)) return loadLocationForEC(caseId); return null; } @Autowired  LocationLoader(AllEligibleCouples allEligibleCouples, AllMothers allMothers, AllChildren allChildren); @Override Location loadLocationFor(String bindType, String caseId);  }
@Test public void shouldReturnLocationFromChildEntityIfBindTypeIsChild() { when(allChildren.findByCaseId("child id 1")).thenReturn(child); locationLoader.loadLocationFor("child", "child id 1"); verify(child).motherCaseId(); verify(mother).ecCaseId(); verify(eligibleCouple).location(); }
@Test public void shouldReturnLocationFromMotherEntityIfBindTypeIsMother() { when(allMothers.findByCaseId("mother id 1")).thenReturn(mother); locationLoader.loadLocationFor("mother", "mother id 1"); verify(mother).ecCaseId(); verify(eligibleCouple).location(); }
@Test public void shouldReturnLocationFromEligibleCoupleEntityIfBindTypeIsEligibleCouple() { when(allEligibleCouples.findByCaseId("ec id 1")).thenReturn(eligibleCouple); locationLoader.loadLocationFor("eligible_couple", "ec id 1"); verify(eligibleCouple).location(); }