### Question:
DisciplineExtractor implements EntityDatedExtract { @Override @SuppressWarnings("unchecked") public void extractEntities(final EntityToEdOrgDateCache diCache) { extract(EntityNames.DISCIPLINE_INCIDENT, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { String id = input.getEntityId(); Map<String, DateTime> edorgDate = diCache.getEntriesById(id); Set<String> edOrgs = new HashSet<String>(); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } return edOrgs; } }); extract(EntityNames.DISCIPLINE_ACTION, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { Set<String> edOrgs = new HashSet<String>(); List<String> students = (List<String>) input.getBody().get("studentId"); for (String student : students) { Map<String, DateTime> edorgDate = studentCache.getEntriesById(student); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } } return edOrgs; } }); } DisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository, EntityToEdOrgDateCache studentCache); @Override @SuppressWarnings("unchecked") void extractEntities(final EntityToEdOrgDateCache diCache);  }### Answer:
@Test public void testExtractDisciplineIncidentAndAction() { Entity da1 = createDisciplineAction("2009-01-01"); Entity da2 = createDisciplineAction("2010-02-13"); Mockito.when(repo.findEach(Mockito.eq("disciplineAction"), Mockito.any(NeutralQuery.class))).thenReturn(Arrays.asList(da1, da2).listIterator(0)); Entity di1 = createDisciplineIncident("2000-02-01"); Entity di2 = createDisciplineIncident("2011-02-01"); Mockito.when(repo.findEach(Mockito.eq("disciplineIncident"), Mockito.any(NeutralQuery.class))).thenReturn(Arrays.asList(di1, di2).listIterator(0)); EntityToEdOrgDateCache diCache = new EntityToEdOrgDateCache(); diCache.addEntry("marker", LEA2, DateTime.parse("2010-02-12", DateHelper.getDateTimeFormat())); diCache.addEntry(DI_ID, LEA2, DateTime.parse("2010-02-12", DateHelper.getDateTimeFormat())); disc.extractEntities(diCache); Mockito.verify(ex, Mockito.times(1)).extractEntity(Mockito.eq(da1), Mockito.any(ExtractFile.class), Mockito.eq("disciplineAction")); Mockito.verify(ex, Mockito.never()).extractEntity(Mockito.eq(da2), Mockito.any(ExtractFile.class), Mockito.eq("disciplineAction")); Mockito.verify(ex, Mockito.times(1)).extractEntity(Mockito.eq(di1), Mockito.any(ExtractFile.class), Mockito.eq("disciplineIncident")); Mockito.verify(ex, Mockito.never()).extractEntity(Mockito.eq(di2), Mockito.any(ExtractFile.class), Mockito.eq("disciplineIncident")); }