Search in sources :

Example 31 with TargetContact

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);
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) TargetAddress(io.atlasmap.java.test.TargetAddress) TargetOrder(io.atlasmap.java.test.TargetOrder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 32 with TargetContact

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);
}
Also used : AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) TargetContact(io.atlasmap.java.test.TargetContact) TargetAddress(io.atlasmap.java.test.TargetAddress) AtlasException(io.atlasmap.api.AtlasException) TargetOrderArray(io.atlasmap.java.test.TargetOrderArray) Field(io.atlasmap.v2.Field) JavaEnumField(io.atlasmap.java.v2.JavaEnumField) JavaField(io.atlasmap.java.v2.JavaField) TestListOrders(io.atlasmap.java.test.TestListOrders) LookupTable(io.atlasmap.v2.LookupTable) TargetOrder(io.atlasmap.java.test.TargetOrder) TargetTestClass(io.atlasmap.java.test.TargetTestClass) Before(org.junit.Before)

Aggregations

TargetContact (io.atlasmap.java.test.TargetContact)32 Test (org.junit.Test)30 AtlasSession (io.atlasmap.api.AtlasSession)25 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)25 AtlasContext (io.atlasmap.api.AtlasContext)13 File (java.io.File)13 TargetTestClass (io.atlasmap.java.test.TargetTestClass)8 BaseContact (io.atlasmap.java.test.BaseContact)7 TargetOrder (io.atlasmap.java.test.TargetOrder)7 TargetAddress (io.atlasmap.java.test.TargetAddress)6 BaseOrder (io.atlasmap.java.test.BaseOrder)4 SourceContact (io.atlasmap.java.test.SourceContact)4 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)3 AtlasException (io.atlasmap.api.AtlasException)2 TestListOrders (io.atlasmap.java.test.TestListOrders)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BaseAddress (io.atlasmap.java.test.BaseAddress)1 StateEnumClassLong (io.atlasmap.java.test.StateEnumClassLong)1 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)1