@Test public void shouldResolveNestedDidWithOptionalNestedReference() throws IOException { NeutralRecordEntity entity = createEntity("NeutralRecord_StudentTranscriptAssoc_missingOptionalEdOrg.json"); DidRefConfig refConfig = createRefConfig("StudentAcademicRecord_optional_ref_config.json"); DidEntityConfig entityConfig = createEntityConfig("StudentTranscriptAssoc_entity_config.json"); AbstractMessageReport errorReport = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); Map<String, String> naturalKeys = new HashMap<String, String>(); naturalKeys.put("schoolId", ""); naturalKeys.put("sessionName", "Spring 2011 East Daybreak Junior High"); naturalKeys.put("schoolId", ""); String tenantId = TENANT; NaturalKeyDescriptor sessionNKD = new NaturalKeyDescriptor(naturalKeys, tenantId, "session", null); Mockito.when(didGenerator.generateId(Mockito.eq(sessionNKD))).thenReturn("sessionDID"); naturalKeys = new HashMap<String, String>(); naturalKeys.put("sessionId", "sessionDID"); NaturalKeyDescriptor studentAcademicRecordNKD = new NaturalKeyDescriptor(naturalKeys, tenantId, "studentAcademicRecord", null); Mockito.when(didGenerator.generateId(Mockito.eq(studentAcademicRecordNKD))).thenReturn( "studentAcademicRecordDID"); mockRefConfig(refConfig, "studentAcademicRecord"); mockEntityConfig(entityConfig, "studentTranscriptAssociation"); Mockito.when(schemaRepository.getSchema(ENTITY_TYPE)).thenReturn(null); didResolver.resolveInternalIds(entity, TENANT, errorReport, reportStats); Object resolvedId = entity.getBody().get("StudentAcademicRecordReference"); Assert.assertEquals("studentAcademicRecordDID", resolvedId); Assert.assertFalse("no errors should be reported from reference resolution ", reportStats.hasErrors()); }
public void resolveInternalIds(NeutralRecordEntity entity, String tenantId, AbstractMessageReport report, ReportStats reportStats) { DidEntityConfig entityConfig = getEntityConfig(entity.getType()); if (entityConfig == null) { return; } if (entityConfig.getReferenceSources() == null || entityConfig.getReferenceSources().isEmpty()) { LOG.debug("Entity configuration contains no references --> returning..."); return; } for (DidRefSource didRefSource : entityConfig.getReferenceSources()) { String referenceEntityType = didRefSource.getEntityType(); String sourceRefPath = didRefSource.getSourceRefPath(); try { handleDeterministicIdForReference(entity, didRefSource, tenantId); } catch (IdResolutionException e) { handleException(entity, sourceRefPath, entity.getType(), referenceEntityType, e, report, reportStats); } } }
DeterministicIdResolver implements BatchJobStage { public void resolveInternalIds(NeutralRecordEntity entity, String tenantId, AbstractMessageReport report, ReportStats reportStats) { DidEntityConfig entityConfig = getEntityConfig(entity.getType()); if (entityConfig == null) { return; } if (entityConfig.getReferenceSources() == null || entityConfig.getReferenceSources().isEmpty()) { LOG.debug("Entity configuration contains no references --> returning..."); return; } for (DidRefSource didRefSource : entityConfig.getReferenceSources()) { String referenceEntityType = didRefSource.getEntityType(); String sourceRefPath = didRefSource.getSourceRefPath(); try { handleDeterministicIdForReference(entity, didRefSource, tenantId); } catch (IdResolutionException e) { handleException(entity, sourceRefPath, entity.getType(), referenceEntityType, e, report, reportStats); } } } }
DeterministicIdResolver implements BatchJobStage { public void resolveInternalIds(NeutralRecordEntity entity, String tenantId, AbstractMessageReport report, ReportStats reportStats) { DidEntityConfig entityConfig = getEntityConfig(entity.getType()); if (entityConfig == null) { return; } if (entityConfig.getReferenceSources() == null || entityConfig.getReferenceSources().isEmpty()) { LOG.debug("Entity configuration contains no references --> returning..."); return; } for (DidRefSource didRefSource : entityConfig.getReferenceSources()) { String referenceEntityType = didRefSource.getEntityType(); String sourceRefPath = didRefSource.getSourceRefPath(); try { handleDeterministicIdForReference(entity, didRefSource, tenantId); } catch (IdResolutionException e) { handleException(entity, sourceRefPath, entity.getType(), referenceEntityType, e, report, reportStats); } } }  }
DeterministicIdResolver implements BatchJobStage { public void resolveInternalIds(NeutralRecordEntity entity, String tenantId, AbstractMessageReport report, ReportStats reportStats) { DidEntityConfig entityConfig = getEntityConfig(entity.getType()); if (entityConfig == null) { return; } if (entityConfig.getReferenceSources() == null || entityConfig.getReferenceSources().isEmpty()) { LOG.debug("Entity configuration contains no references --> returning..."); return; } for (DidRefSource didRefSource : entityConfig.getReferenceSources()) { String referenceEntityType = didRefSource.getEntityType(); String sourceRefPath = didRefSource.getSourceRefPath(); try { handleDeterministicIdForReference(entity, didRefSource, tenantId); } catch (IdResolutionException e) { handleException(entity, sourceRefPath, entity.getType(), referenceEntityType, e, report, reportStats); } } }  void resolveInternalIds(NeutralRecordEntity entity, String tenantId, AbstractMessageReport report,
                                   ReportStats reportStats); DidSchemaParser getDidSchemaParser(); void setDidSchemaParser(DidSchemaParser didSchemaParser); @Override String getStageName(); }
DeterministicIdResolver implements BatchJobStage { public void resolveInternalIds(NeutralRecordEntity entity, String tenantId, AbstractMessageReport report, ReportStats reportStats) { DidEntityConfig entityConfig = getEntityConfig(entity.getType()); if (entityConfig == null) { return; } if (entityConfig.getReferenceSources() == null || entityConfig.getReferenceSources().isEmpty()) { LOG.debug("Entity configuration contains no references --> returning..."); return; } for (DidRefSource didRefSource : entityConfig.getReferenceSources()) { String referenceEntityType = didRefSource.getEntityType(); String sourceRefPath = didRefSource.getSourceRefPath(); try { handleDeterministicIdForReference(entity, didRefSource, tenantId); } catch (IdResolutionException e) { handleException(entity, sourceRefPath, entity.getType(), referenceEntityType, e, report, reportStats); } } }  void resolveInternalIds(NeutralRecordEntity entity, String tenantId, AbstractMessageReport report,
                                   ReportStats reportStats); DidSchemaParser getDidSchemaParser(); void setDidSchemaParser(DidSchemaParser didSchemaParser); @Override String getStageName();  }