ReporterFactory implements IReporterFactory { public IReporter reporterFor(String entityType) { if (entityType.equalsIgnoreCase(CHILD_TYPE)) return childReporter; if (entityType.equalsIgnoreCase(MOTHER_TYPE)) return motherReporter; if (entityType.equalsIgnoreCase(ELIGIBLE_COUPLE_TYPE)) return eligibleCoupleReporter; return null; } @Autowired  ReporterFactory(EligibleCoupleReporter eligibleCoupleReporter, MotherReporter motherReporter, ChildReporter childReporter); IReporter reporterFor(String entityType);  }
@Test public void shouldReturnChildReporterWhenBindTypeIsChild() { IReporter reporter = reporterFactory.reporterFor("child"); assertTrue(reporter instanceof ChildReporter); }
@Test public void shouldReturnMotherReporterWhenBindTypeIsMother() { IReporter reporter = reporterFactory.reporterFor("mother"); assertTrue(reporter instanceof MotherReporter); }
@Test public void shouldReturnEligibleCoupleReporterWhenBindTypeIsEligibleCouple() { IReporter reporter = reporterFactory.reporterFor("eligible_couple"); assertTrue(reporter instanceof EligibleCoupleReporter); }
@Test public void shouldReturnNullWhenBindTypeIsNotMatched() { IReporter reporter = reporterFactory.reporterFor("NonExistentBindType"); assertNull(reporter); }