### Question:
EntityExtractor { public void extractEntities(ExtractFile archiveFile, String collectionName, Predicate<Entity> filter) { audit(securityEventUtil.createSecurityEvent(this.getClass().getName(), " Entity extraction", LogLevelType.TYPE_INFO, BEMessageCode.BE_SE_CODE_0024, collectionName)); if (extractionQuery == null) { extractionQuery = new NeutralQuery(); } Iterator<Entity> cursor = entityRepository.findEach(collectionName, extractionQuery); if (cursor.hasNext()) { LOG.info("Extracting from " + collectionName); CollectionWrittenRecord collectionRecord = new CollectionWrittenRecord(collectionName); while (cursor.hasNext()) { Entity entity = cursor.next(); write(entity, archiveFile, collectionRecord, filter); } LOG.info("Finished extracting " + collectionRecord.toString()); } }  void extractEntities(ExtractFile archiveFile, String collectionName, Predicate<Entity> filter); void extractEntity(Entity entity, ExtractFile archiveFile, String collectionName, Predicate<Entity> filter); void extractEntity(Entity entity, ExtractFile archiveFile, String collectionName); void extractEmbeddedEntities(Entity entity, ExtractFile archiveFile, String collectionName, Predicate<Entity> filter); void write(Entity entity, ExtractFile archiveFile, CollectionWrittenRecord collectionRecord, Predicate<Entity> filter); void setEntityRepository(Repository<Entity> entityRepository); void setExtractionQuery(NeutralQuery extractionQuery); void setWriter(EntityWriterManager writer);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testExtractEntities() throws IOException { String testTenant = "Midgar"; String testEntity = "student"; Iterator<Entity> cursor = Mockito.mock(Iterator.class); List<Entity> students = TestUtils.createStudents(); Mockito.when(cursor.hasNext()).thenReturn(true, true, true, false); Mockito.when(cursor.next()).thenReturn(students.get(0), students.get(1)); Mockito.when(mongoEntityRepository.findEach(Matchers.eq(testEntity), Matchers.any(NeutralQuery.class))).thenReturn(cursor); extractor.extractEntities(archiveFile, testEntity, null); Mockito.verify(mongoEntityRepository, Mockito.times(1)).findEach("student", new NeutralQuery()); Mockito.verify(writer, Mockito.times(2)).write(Mockito.any(Entity.class), Mockito.any(ExtractFile.class)); }