@Test public void testOneStudentOneLea() { Map<String, DateTime> edOrgDate = new HashMap<String, DateTime>(); edOrgDate.put("LEA-1", DateTime.now()); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-1"))).thenReturn(edOrgDate); Entity e = Mockito.mock(Entity.class); Map entityBody = new HashMap<String, Object>(); entityBody.put("studentId", "student-1"); entityBody.put(ParameterConstants.ENTRY_DATE, "2013-01-01"); Mockito.when(e.getBody()).thenReturn(entityBody); Mockito.when(e.getType()).thenReturn(EntityNames.STUDENT_SCHOOL_ASSOCIATION); Mockito.when(mockRepo.findEach(Mockito.eq("studentSchoolAssociation"), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(e).iterator()); ssaExtractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(1)).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("studentSchoolAssociation")); }
@Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } }
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } }
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); }
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache);  }