@Test public void testProcessTargetFieldMapping() throws Exception { PropertyField field = mock(PropertyField.class); when(field.getName()).thenReturn("testProp"); when(field.getValue()).thenReturn("testValue"); Head head = mock(Head.class); when(head.getTargetField()).thenReturn(field); AtlasInternalSession session = mock(AtlasInternalSession.class); when(session.head()).thenReturn(head); Map<String, Object> targetProps = new HashMap<>(); when(session.getTargetProperties()).thenReturn(targetProps); DefaultAtlasConversionService atlasConversionService = mock(DefaultAtlasConversionService.class); when(atlasConversionService.fieldTypeFromClass(any(String.class))).thenReturn(FieldType.ANY); module.setConversionService(atlasConversionService); module.writeTargetValue(session); assertEquals("testValue", targetProps.get("testProp")); }
@Override public void writeTargetValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field targetField = session.head().getTargetField(); if (targetField instanceof PropertyField) { PropertyField targetPropertyField = (PropertyField)targetField; strategy.writeProperty(session, targetPropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed target PropertyField: Name={} Value={} Strategy={}", targetPropertyField.getName(), targetPropertyField.getValue(), strategy.getClass().getName()); } } }
PropertyModule extends BaseAtlasModule { @Override public void writeTargetValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field targetField = session.head().getTargetField(); if (targetField instanceof PropertyField) { PropertyField targetPropertyField = (PropertyField)targetField; strategy.writeProperty(session, targetPropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed target PropertyField: Name={} Value={} Strategy={}", targetPropertyField.getName(), targetPropertyField.getValue(), strategy.getClass().getName()); } } } }
PropertyModule extends BaseAtlasModule { @Override public void writeTargetValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field targetField = session.head().getTargetField(); if (targetField instanceof PropertyField) { PropertyField targetPropertyField = (PropertyField)targetField; strategy.writeProperty(session, targetPropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed target PropertyField: Name={} Value={} Strategy={}", targetPropertyField.getName(), targetPropertyField.getValue(), strategy.getClass().getName()); } } } PropertyModule(AtlasPropertyStrategy propertyStrategy); }
PropertyModule extends BaseAtlasModule { @Override public void writeTargetValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field targetField = session.head().getTargetField(); if (targetField instanceof PropertyField) { PropertyField targetPropertyField = (PropertyField)targetField; strategy.writeProperty(session, targetPropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed target PropertyField: Name={} Value={} Strategy={}", targetPropertyField.getName(), targetPropertyField.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 writeTargetValue(AtlasInternalSession session) throws AtlasException { AtlasPropertyStrategy strategy = session.getAtlasPropertyStrategy() != null ? session.getAtlasPropertyStrategy() : this.defaultStrategy; Field targetField = session.head().getTargetField(); if (targetField instanceof PropertyField) { PropertyField targetPropertyField = (PropertyField)targetField; strategy.writeProperty(session, targetPropertyField); if (LOG.isDebugEnabled()) { LOG.debug("Processed target PropertyField: Name={} Value={} Strategy={}", targetPropertyField.getName(), targetPropertyField.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);  }