@Test public void testOneExtractedEntity() { Entity e = Mockito.mock(Entity.class); Mockito.when(mockRepo.findEach(Mockito.eq("student"), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(e).iterator()); Map<String, DateTime> datedEdorgs = new HashMap<String, DateTime>(); datedEdorgs.put("LEA", DateTime.now()); Mockito.when(helper.fetchAllEdOrgsForStudent(Mockito.any(Entity.class))).thenReturn(datedEdorgs); extractor.extractEntities(null); Mockito.verify(mockExtractor).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("student"), Mockito.any(Predicate.class)); }
@Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } }
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } }
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
                            ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); }
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
                            ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgCache dummyCache); EntityToEdOrgCache getParentCache(); EntityToEdOrgDateCache getStudentDatedCache(); EntityToEdOrgDateCache getDiDateCache(); }
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
                            ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgCache dummyCache); EntityToEdOrgCache getParentCache(); EntityToEdOrgDateCache getStudentDatedCache(); EntityToEdOrgDateCache getDiDateCache();  }