@Test public void testProcessSourceFieldMapping() throws AtlasException { PropertyField field = mock(PropertyField.class); when(field.getName()).thenReturn("testProp"); Head head = mock(Head.class); when(head.getSourceField()).thenReturn(field); AtlasInternalSession session = mock(AtlasInternalSession.class); when(session.head()).thenReturn(head); Map<String, Object> sourceProps = new HashMap<>(); sourceProps.put("testProp", "testValue"); when(session.getSourceProperties()).thenReturn(sourceProps); DefaultAtlasConversionService atlasConversionService = mock(DefaultAtlasConversionService.class); when(atlasConversionService.fieldTypeFromClass(any(String.class))).thenReturn(FieldType.ANY); module.setConversionService(atlasConversionService); module.readSourceValue(session); ArgumentCaptor<Object> arg = ArgumentCaptor.forClass(Object.class); verify(field).setValue(arg.capture()); assertEquals("testValue", arg.getValue()); }
@Override public void readSourceValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field sourceField = session.head().getSourceField(); if (sourceField instanceof PropertyField) { PropertyField sourcePropertyField = (PropertyField)sourceField; strategy.readProperty(session, sourcePropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed source PropertyField: Name={} Scope={} Value={} Strategy={}", sourcePropertyField.getName(), sourcePropertyField.getScope(), sourceField.getValue(), strategy.getClass().getName()); } } }
PropertyModule extends BaseAtlasModule { @Override public void readSourceValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field sourceField = session.head().getSourceField(); if (sourceField instanceof PropertyField) { PropertyField sourcePropertyField = (PropertyField)sourceField; strategy.readProperty(session, sourcePropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed source PropertyField: Name={} Scope={} Value={} Strategy={}", sourcePropertyField.getName(), sourcePropertyField.getScope(), sourceField.getValue(), strategy.getClass().getName()); } } } }
PropertyModule extends BaseAtlasModule { @Override public void readSourceValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field sourceField = session.head().getSourceField(); if (sourceField instanceof PropertyField) { PropertyField sourcePropertyField = (PropertyField)sourceField; strategy.readProperty(session, sourcePropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed source PropertyField: Name={} Scope={} Value={} Strategy={}", sourcePropertyField.getName(), sourcePropertyField.getScope(), sourceField.getValue(), strategy.getClass().getName()); } } } PropertyModule(AtlasPropertyStrategy propertyStrategy); }
PropertyModule extends BaseAtlasModule { @Override public void readSourceValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field sourceField = session.head().getSourceField(); if (sourceField instanceof PropertyField) { PropertyField sourcePropertyField = (PropertyField)sourceField; strategy.readProperty(session, sourcePropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed source PropertyField: Name={} Scope={} Value={} Strategy={}", sourcePropertyField.getName(), sourcePropertyField.getScope(), sourceField.getValue(), strategy.getClass().getName()); } } } PropertyModule(AtlasPropertyStrategy propertyStrategy); @Override void processPreValidation(AtlasInternalSession session); @Override void processPreSourceExecution(AtlasInternalSession session); @Override void readSourceValue(AtlasInternalSession session); @Override void processPostSourceExecution(AtlasInternalSession session); @Override void processPreTargetExecution(AtlasInternalSession session); @Override void writeTargetValue(AtlasInternalSession session); @Override void processPostTargetExecution(AtlasInternalSession session); @Override void processPostValidation(AtlasInternalSession session); @Override Boolean isSupportedField(Field field); @Override PropertyField cloneField(Field field); }
PropertyModule extends BaseAtlasModule { @Override public void readSourceValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field sourceField = session.head().getSourceField(); if (sourceField instanceof PropertyField) { PropertyField sourcePropertyField = (PropertyField)sourceField; strategy.readProperty(session, sourcePropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed source PropertyField: Name={} Scope={} Value={} Strategy={}", sourcePropertyField.getName(), sourcePropertyField.getScope(), sourceField.getValue(), strategy.getClass().getName()); } } } PropertyModule(AtlasPropertyStrategy propertyStrategy); @Override void processPreValidation(AtlasInternalSession session); @Override void processPreSourceExecution(AtlasInternalSession session); @Override void readSourceValue(AtlasInternalSession session); @Override void processPostSourceExecution(AtlasInternalSession session); @Override void processPreTargetExecution(AtlasInternalSession session); @Override void writeTargetValue(AtlasInternalSession session); @Override void processPostTargetExecution(AtlasInternalSession session); @Override void processPostValidation(AtlasInternalSession session); @Override Boolean isSupportedField(Field field); @Override PropertyField cloneField(Field field);  }