### Question:
StaffExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffToEdorgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF, this.getClass().getName()); Iterator<Entity> staffs = repo.findEach(EntityNames.STAFF, new NeutralQuery()); while (staffs.hasNext()) { Entity staff = staffs.next(); Set<String> edOrgs = staffToEdorgDateCache.getEntriesById(staff.getEntityId()).keySet(); for (String edOrg : edOrgs) { extractor.extractEntity(staff, map.getExtractFileForEdOrg(edOrg), EntityNames.STAFF); } } } StaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffToEdorgDateCache);  }### Answer:
@Test public void testExtractOneEntity() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaDateCache); Mockito.verify(mockExtractor).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF)); }
@Test public void testExtractManyEntity() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity, mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaDateCache); Mockito.verify(mockExtractor, Mockito.times(2)).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF)); }
@Test public void testExtractNoEntityBecauseOfLEAMiss() { Mockito.when(mockEntity.getEntityId()).thenReturn("Staff2"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(null); extractor.extractEntities(staffToLeaDateCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF)); }