@Test public void testWriteSomeEntities() { Entity saEntity = Mockito.mock(Entity.class); Map<String, Object> saEntityBody = new HashMap<String, Object>(); saEntityBody.put("administrationDate", "3000-12-21"); saEntityBody.put(ParameterConstants.STUDENT_ID, "student"); Mockito.when(saEntity.getBody()).thenReturn(saEntityBody); Mockito.when(saEntity.getType()).thenReturn(EntityNames.STUDENT_ASSESSMENT); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STUDENT_ASSESSMENT), Mockito.eq(new NeutralQuery()))) .thenReturn( Arrays.asList(mockEntity, saEntity).iterator()); entityBody.put(ParameterConstants.STUDENT_ID, "student"); extractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(1)).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); Mockito.verify(mockExtractor, Mockito.times(0)).extractEntity(Mockito.eq(saEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); }
@Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } }
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } }
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache);  }