@Test public void shouldIgnoreOptionalEmptyRefs() throws IOException { NeutralRecordEntity entity = createSourceEntity(); DidRefConfig refConfig = createRefConfig("Simple_DID_ref_config.json"); DidEntityConfig entityConfig = createEntityConfig("optional_DID_entity_config.json"); mockRefConfig(refConfig, ENTITY_TYPE); mockEntityConfig(entityConfig, ENTITY_TYPE); Mockito.when(schemaRepository.getSchema(ENTITY_TYPE)).thenReturn(null); Map<String, String> naturalKeys = new HashMap<String, String>(); naturalKeys.put(SRC_KEY_FIELD, SRC_KEY_VALUE); String entityType = ENTITY_TYPE; String tenantId = TENANT; NaturalKeyDescriptor ndk = new NaturalKeyDescriptor(naturalKeys, tenantId, entityType, null); Mockito.when(didGenerator.generateId(Mockito.eq(ndk))).thenReturn(DID_VALUE); AbstractMessageReport errorReport = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); didResolver.resolveInternalIds(entity, TENANT, errorReport, reportStats); Assert.assertEquals(DID_VALUE, entity.getBody().get(REF_FIELD)); 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();  }