@Test public void shouldResolveListOfReferences() throws IOException { NeutralRecordEntity entity = createSourceEntityWithRefList(); DidRefConfig refConfig = createRefConfig("Simple_DID_ref_config.json"); DidEntityConfig entityConfig = createEntityConfig("Simple_DID_entity_config.json"); mockRefConfig(refConfig, ENTITY_TYPE); mockEntityConfig(entityConfig, ENTITY_TYPE); Mockito.when(schemaRepository.getSchema(ENTITY_TYPE)).thenReturn(null); Map<String, String> naturalKeys1 = new HashMap<String, String>(); naturalKeys1.put(SRC_KEY_FIELD, SRC_KEY_VALUE_1); NaturalKeyDescriptor ndk1 = new NaturalKeyDescriptor(naturalKeys1, TENANT, ENTITY_TYPE, null); Map<String, String> naturalKeys2 = new HashMap<String, String>(); naturalKeys2.put(SRC_KEY_FIELD, SRC_KEY_VALUE_2); NaturalKeyDescriptor ndk2 = new NaturalKeyDescriptor(naturalKeys2, TENANT, ENTITY_TYPE, null); Mockito.when(didGenerator.generateId(Mockito.eq(ndk1))).thenReturn(DID_VALUE_1); Mockito.when(didGenerator.generateId(Mockito.eq(ndk2))).thenReturn(DID_VALUE_2); AbstractMessageReport errorReport = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); didResolver.resolveInternalIds(entity, TENANT, errorReport, reportStats); @SuppressWarnings("unchecked") List<String> did_list = (List<String>) entity.getBody().get(REF_FIELD); Assert.assertNotNull(did_list); Assert.assertEquals(2, did_list.size()); Assert.assertEquals(DID_VALUE_1, did_list.get(0)); Assert.assertEquals(DID_VALUE_2, did_list.get(1)); 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();  }