@Test public void testApply() { Map<String, Object> body = new HashMap<String, Object>(); body.put("schoolYear", "schoolYear"); List<Map<String,Object>> attendanceEvent = new ArrayList<Map<String,Object>>(); body.put("attendanceEvent", attendanceEvent); Entity entity = new BulkExtractEntity(body, "student"); Entity treated = treat.apply(entity); Assert.assertNotNull(treated.getBody().get("schoolYearAttendance")); List<Map<String, Object>> attendances = new ArrayList<Map<String, Object>>(); Map<String, Object> schoolYearAttendance = new HashMap<String, Object>(); attendances = (List<Map<String, Object>>) treated.getBody().get("schoolYearAttendance"); schoolYearAttendance = attendances.get(0); Assert.assertNotNull(schoolYearAttendance.get("schoolYear")); Assert.assertNotNull(schoolYearAttendance.get("attendanceEvent")); Assert.assertEquals("schoolYear", schoolYearAttendance.get("schoolYear")); Assert.assertNotNull(schoolYearAttendance.get("attendanceEvent")); }
@Override public Entity apply(Entity entity) { if (entity.getBody().containsKey("schoolYearAttendance")) { LOG.debug("Treatment has already been applied to attendance entity: {}", new Object[] { entity.getEntityId() }); return entity; } Map<String,Object> treated = AttendanceStrategyHelper.wrap(entity.getBody()); entity.getBody().clear(); entity.getBody().putAll(treated); return entity; }
AttendanceTreatment implements Treatment { @Override public Entity apply(Entity entity) { if (entity.getBody().containsKey("schoolYearAttendance")) { LOG.debug("Treatment has already been applied to attendance entity: {}", new Object[] { entity.getEntityId() }); return entity; } Map<String,Object> treated = AttendanceStrategyHelper.wrap(entity.getBody()); entity.getBody().clear(); entity.getBody().putAll(treated); return entity; } }
AttendanceTreatment implements Treatment { @Override public Entity apply(Entity entity) { if (entity.getBody().containsKey("schoolYearAttendance")) { LOG.debug("Treatment has already been applied to attendance entity: {}", new Object[] { entity.getEntityId() }); return entity; } Map<String,Object> treated = AttendanceStrategyHelper.wrap(entity.getBody()); entity.getBody().clear(); entity.getBody().putAll(treated); return entity; }  }
AttendanceTreatment implements Treatment { @Override public Entity apply(Entity entity) { if (entity.getBody().containsKey("schoolYearAttendance")) { LOG.debug("Treatment has already been applied to attendance entity: {}", new Object[] { entity.getEntityId() }); return entity; } Map<String,Object> treated = AttendanceStrategyHelper.wrap(entity.getBody()); entity.getBody().clear(); entity.getBody().putAll(treated); return entity; }  @Override Entity apply(Entity entity); }
AttendanceTreatment implements Treatment { @Override public Entity apply(Entity entity) { if (entity.getBody().containsKey("schoolYearAttendance")) { LOG.debug("Treatment has already been applied to attendance entity: {}", new Object[] { entity.getEntityId() }); return entity; } Map<String,Object> treated = AttendanceStrategyHelper.wrap(entity.getBody()); entity.getBody().clear(); entity.getBody().putAll(treated); return entity; }  @Override Entity apply(Entity entity);  }