use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaWriterUtilTest method testSetObjectOnParent.
@Test
public void testSetObjectOnParent() throws Exception {
JavaWriterUtil writerUtil = new JavaWriterUtil(DefaultAtlasConversionService.getInstance());
reset();
setupPath("/contact");
targetTestClassInstance.setContact(null);
TargetContact testContact = new TargetContact();
writerUtil.setObjectOnParent(field, lastSegmentContext, targetTestClassInstance, testContact);
assertTrue(targetTestClassInstance.getContact() == testContact);
reset();
setupPath("/address");
targetTestClassInstance.setAddress(null);
TargetAddress testAddress = new TargetAddress();
writerUtil.setObjectOnParent(field, lastSegmentContext, targetTestClassInstance, testAddress);
assertTrue(targetTestClassInstance.getAddress() == testAddress);
reset();
setupPath("/address/addressLine1");
targetTestClassInstance.getAddress().setAddressLine1(null);
String addressLine1 = "123 any street";
writerUtil.setObjectOnParent(field, lastSegmentContext, targetTestClassInstance.getAddress(), addressLine1);
assertTrue(targetTestClassInstance.getAddress().getAddressLine1() == addressLine1);
reset();
setupPath("/listOrders/orders<5>");
List<TargetOrder> testListOrders = new LinkedList<>();
targetTestClassInstance.getListOrders().setOrders(null);
writerUtil.setObjectOnParent(field, lastSegmentContext, targetTestClassInstance.getListOrders(), testListOrders);
assertTrue(((Object) targetTestClassInstance.getListOrders().getOrders()) == testListOrders);
reset();
setupPath("/orderArray/orders[10]");
targetTestClassInstance.getOrderArray().setOrders(null);
Object[] testArrayOrders = new TargetOrder[12];
writerUtil.setObjectOnParent(field, lastSegmentContext, targetTestClassInstance.getOrderArray(), testArrayOrders);
assertTrue(targetTestClassInstance.getOrderArray().getOrders() == testArrayOrders);
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class BaseDocumentWriterTest method reset.
@Before
public void reset() {
classLoader = Thread.currentThread().getContextClassLoader();
writer = new DocumentJavaFieldWriter(conversionService);
writer.setTargetValueConverter(new TargetValueConverter(classLoader, conversionService) {
public Object convert(AtlasInternalSession session, LookupTable lookupTable, Field sourceField, Object parentObject, Field targetField) throws AtlasException {
return targetField.getValue();
}
});
field = null;
segmentContexts = new LinkedList<>();
targetTestClassInstance = new TargetTestClass();
targetTestClassInstance.setContact(new TargetContact());
targetTestClassInstance.setAddress(new TargetAddress());
targetOrderListInstance = new TestListOrders();
targetOrderListInstance.setOrders(new LinkedList<>());
targetOrderListInstance.getOrders().add(new TargetOrder());
targetOrderListInstance.getOrders().add(new TargetOrder());
targetTestClassInstance.setListOrders(targetOrderListInstance);
targetOrderArrayInstance = new TargetOrderArray();
targetOrderArrayInstance.setOrders(new BaseOrder[2]);
targetOrderArrayInstance.getOrders()[0] = new TargetOrder();
targetOrderArrayInstance.getOrders()[1] = new TargetOrder();
targetTestClassInstance.setOrderArray(targetOrderArrayInstance);
}
Aggregations