@Test public void testAssessmentsWithAIsInOAsToAPI() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Entity oldAssessment = createHierarchicalUpConvertEntity(); Entity assessment = assessmentConverter.subdocToBodyField(oldAssessment); assertEquals("somevalue1", PropertyUtils.getProperty(assessment, "body.objectiveAssessment.[0].objectiveAssessments.[0].assessmentItem.[0].abc")); assertEquals("somevalue2", PropertyUtils.getProperty(assessment, "body.objectiveAssessment.[0].objectiveAssessments.[1].assessmentItem.[0].abc")); assertEquals("somevalue3", PropertyUtils.getProperty(assessment, "body.objectiveAssessment.[0].objectiveAssessments.[0].assessmentItem.[1].abc")); assertEquals("somevalue4", PropertyUtils.getProperty(assessment, "body.assessmentItem.[0].abc")); assertNull(PropertyUtils.getProperty(assessment, "body.objectiveAssessment.[0].objectiveAssessments.[0].assessmentItem.[0]._id")); assertNull(PropertyUtils.getProperty(assessment, "body.objectiveAssessment.[0].objectiveAssessments.[0].assessmentItem.[0].assessmentId")); }
@Override public Entity subdocToBodyField(Entity entity) { if (entity != null && entity.getType().equals(ASSESSMENT)) { if (entity.getBody() == null || entity.getBody().isEmpty()) { return null; } transformToHierarchy(entity); subdocsToBody(entity, ASSESSMENT_ITEM, ASSESSMENT_ITEM, Arrays.asList(ASSESSMENT_ID)); subdocsToBody(entity, OBJECTIVE_ASSESSMENT, OBJECTIVE_ASSESSMENT, Arrays.asList(ASSESSMENT_ID)); entity.getEmbeddedData().clear(); collapseAssessmentPeriodDescriptor(entity); addFamilyHierarchy(entity); } return entity; }
AssessmentConverter extends GenericSuperdocConverter implements SuperdocConverter { @Override public Entity subdocToBodyField(Entity entity) { if (entity != null && entity.getType().equals(ASSESSMENT)) { if (entity.getBody() == null || entity.getBody().isEmpty()) { return null; } transformToHierarchy(entity); subdocsToBody(entity, ASSESSMENT_ITEM, ASSESSMENT_ITEM, Arrays.asList(ASSESSMENT_ID)); subdocsToBody(entity, OBJECTIVE_ASSESSMENT, OBJECTIVE_ASSESSMENT, Arrays.asList(ASSESSMENT_ID)); entity.getEmbeddedData().clear(); collapseAssessmentPeriodDescriptor(entity); addFamilyHierarchy(entity); } return entity; } }
AssessmentConverter extends GenericSuperdocConverter implements SuperdocConverter { @Override public Entity subdocToBodyField(Entity entity) { if (entity != null && entity.getType().equals(ASSESSMENT)) { if (entity.getBody() == null || entity.getBody().isEmpty()) { return null; } transformToHierarchy(entity); subdocsToBody(entity, ASSESSMENT_ITEM, ASSESSMENT_ITEM, Arrays.asList(ASSESSMENT_ID)); subdocsToBody(entity, OBJECTIVE_ASSESSMENT, OBJECTIVE_ASSESSMENT, Arrays.asList(ASSESSMENT_ID)); entity.getEmbeddedData().clear(); collapseAssessmentPeriodDescriptor(entity); addFamilyHierarchy(entity); } return entity; }  }
AssessmentConverter extends GenericSuperdocConverter implements SuperdocConverter { @Override public Entity subdocToBodyField(Entity entity) { if (entity != null && entity.getType().equals(ASSESSMENT)) { if (entity.getBody() == null || entity.getBody().isEmpty()) { return null; } transformToHierarchy(entity); subdocsToBody(entity, ASSESSMENT_ITEM, ASSESSMENT_ITEM, Arrays.asList(ASSESSMENT_ID)); subdocsToBody(entity, OBJECTIVE_ASSESSMENT, OBJECTIVE_ASSESSMENT, Arrays.asList(ASSESSMENT_ID)); entity.getEmbeddedData().clear(); collapseAssessmentPeriodDescriptor(entity); addFamilyHierarchy(entity); } return entity; }  @Override Entity subdocToBodyField(Entity entity); @Override void bodyFieldToSubdoc(Entity entity); @Override void bodyFieldToSubdoc(Entity entity, SuperdocConverter.Option option); List<Map<String, Object>> extractAssessmentItems(List<Entity> objectiveAssessments, String parentKey); @Override Iterable<Entity> subdocToBodyField(Iterable<Entity> entities); @Override void bodyFieldToSubdoc(Iterable<Entity> entities); @Override void bodyFieldToSubdoc(Iterable<Entity> entities, SuperdocConverter.Option option); }
AssessmentConverter extends GenericSuperdocConverter implements SuperdocConverter { @Override public Entity subdocToBodyField(Entity entity) { if (entity != null && entity.getType().equals(ASSESSMENT)) { if (entity.getBody() == null || entity.getBody().isEmpty()) { return null; } transformToHierarchy(entity); subdocsToBody(entity, ASSESSMENT_ITEM, ASSESSMENT_ITEM, Arrays.asList(ASSESSMENT_ID)); subdocsToBody(entity, OBJECTIVE_ASSESSMENT, OBJECTIVE_ASSESSMENT, Arrays.asList(ASSESSMENT_ID)); entity.getEmbeddedData().clear(); collapseAssessmentPeriodDescriptor(entity); addFamilyHierarchy(entity); } return entity; }  @Override Entity subdocToBodyField(Entity entity); @Override void bodyFieldToSubdoc(Entity entity); @Override void bodyFieldToSubdoc(Entity entity, SuperdocConverter.Option option); List<Map<String, Object>> extractAssessmentItems(List<Entity> objectiveAssessments, String parentKey); @Override Iterable<Entity> subdocToBodyField(Iterable<Entity> entities); @Override void bodyFieldToSubdoc(Iterable<Entity> entities); @Override void bodyFieldToSubdoc(Iterable<Entity> entities, SuperdocConverter.Option option);  }