@Test public void testshouldExtractEntityBeforeAndAfterTreatment() { Map<String, Object> entityBody = new HashMap<String, Object>(); entityBody.put(ParameterConstants.SCHOOL_YEAR, "2009-2010"); Entity attendance = Mockito.mock(Entity.class); Mockito.when(attendance.getType()).thenReturn(EntityNames.ATTENDANCE); Mockito.when(attendance.getBody()).thenReturn(entityBody); Assert.assertTrue(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()))); entityBody.clear(); List<Map<String, Object>> schoolYearAttendances = new ArrayList<Map<String, Object>>(); Map<String, Object> schoolYearAttendance = new HashMap<String, Object>(); schoolYearAttendance.put(ParameterConstants.SCHOOL_YEAR, "2009-2010"); schoolYearAttendances.add(schoolYearAttendance); entityBody.put("schoolYearAttendance", schoolYearAttendances); Assert.assertTrue(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()))); Assert.assertTrue(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2010-05-23", DateHelper.getDateTimeFormat()))); Assert.assertFalse(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2009-05-24", DateHelper.getDateTimeFormat()))); Assert.assertFalse(attendanceExtractVerifier.shouldExtract(attendance, DateTime.parse("2008-05-24", DateHelper.getDateTimeFormat()))); }
@Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); }
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); } }
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); }  }
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); }  @Override boolean shouldExtract(Entity entity, DateTime upToDate); }
AttendanceExtractVerifier implements ExtractVerifier { @Override public boolean shouldExtract(Entity entity, DateTime upToDate) { String schoolYear = null; if (entity.getBody().containsKey("schoolYearAttendance")) { schoolYear = (String) ((List<Map<String, Object>>) entity.getBody().get("schoolYearAttendance")).get(0).get("schoolYear"); } else { schoolYear = EntityDateHelper.retrieveDate(entity); } return EntityDateHelper.isPastOrCurrentDate(schoolYear, upToDate, entity.getType()); }  @Override boolean shouldExtract(Entity entity, DateTime upToDate);  }