Search in sources :

Example 1 with SourceAddress

use of io.atlasmap.java.test.SourceAddress in project atlasmap by atlasmap.

the class ClassHelperTest method testParentObjectForPathGrandParent.

@Test
public void testParentObjectForPathGrandParent() throws Exception {
    SourceAddress sourceAddress = new SourceAddress();
    SourceOrder sourceOrder = new SourceOrder();
    sourceOrder.setAddress(sourceAddress);
    SourceParentOrder sourceParentOrder = new SourceParentOrder();
    sourceParentOrder.setOrder(sourceOrder);
    Object parentObject = ClassHelper.parentObjectForPath(sourceParentOrder, new AtlasPath("/order/address/city"), true);
    assertNotNull(parentObject);
    assertTrue(parentObject instanceof SourceAddress);
    assertEquals(sourceAddress, parentObject);
}
Also used : SourceAddress(io.atlasmap.java.test.SourceAddress) SourceParentOrder(io.atlasmap.java.test.SourceParentOrder) SourceOrder(io.atlasmap.java.test.SourceOrder) AtlasPath(io.atlasmap.core.AtlasPath) Test(org.junit.Test)

Example 2 with SourceAddress

use of io.atlasmap.java.test.SourceAddress in project atlasmap by atlasmap.

the class JavaConstructServiceComplexArrayTest method testConstructSourceOrderArray.

@Test
public void testConstructSourceOrderArray() throws Exception {
    Object targetObject = constructService.constructClass(generateOrderArray("Source"), null);
    assertNotNull(targetObject);
    assertTrue(targetObject instanceof SourceOrderArray);
    SourceOrderArray orderArray = (SourceOrderArray) targetObject;
    assertNotNull(orderArray.getOrders());
    assertTrue(orderArray.getOrders().length > 0);
    for (int i = 0; i < orderArray.getOrders().length; i++) {
        SourceOrder order = (SourceOrder) orderArray.getOrders()[i];
        assertNotNull(order.getAddress());
        assertTrue(order.getAddress() instanceof SourceAddress);
        SourceAddress address = (SourceAddress) order.getAddress();
        assertNull(address.getAddressLine1());
        assertNull(address.getAddressLine2());
        assertNull(address.getCity());
        assertNull(address.getState());
        assertNull(address.getZipCode());
        assertNotNull(order.getContact());
        assertTrue(order.getContact() instanceof SourceContact);
        SourceContact contact = (SourceContact) order.getContact();
        assertNull(contact.getFirstName());
        assertNull(contact.getLastName());
        assertNull(contact.getPhoneNumber());
        assertNull(contact.getZipCode());
    }
}
Also used : SourceAddress(io.atlasmap.java.test.SourceAddress) SourceOrderArray(io.atlasmap.java.test.SourceOrderArray) SourceOrder(io.atlasmap.java.test.SourceOrder) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test)

Example 3 with SourceAddress

use of io.atlasmap.java.test.SourceAddress in project atlasmap by atlasmap.

the class ClassHelperTest method testParentObjectForPath.

@Test
public void testParentObjectForPath() throws Exception {
    SourceAddress sourceAddress = new SourceAddress();
    SourceOrder sourceOrder = new SourceOrder();
    sourceOrder.setAddress(sourceAddress);
    Object parentObject = ClassHelper.parentObjectForPath(sourceOrder, new AtlasPath("/address/city"), true);
    assertNotNull(parentObject);
    assertTrue(parentObject instanceof SourceAddress);
    assertEquals(sourceAddress, parentObject);
}
Also used : SourceAddress(io.atlasmap.java.test.SourceAddress) SourceOrder(io.atlasmap.java.test.SourceOrder) AtlasPath(io.atlasmap.core.AtlasPath) Test(org.junit.Test)

Example 4 with SourceAddress

use of io.atlasmap.java.test.SourceAddress in project atlasmap by atlasmap.

the class JavaConstructServiceComplexTest method testConstructSourceParentOrder.

@Test
public void testConstructSourceParentOrder() throws Exception {
    JavaClass javaClass = generateParentOrder("Source");
    Object targetObject = constructService.constructClass(javaClass, null);
    assertNotNull(targetObject);
    assertTrue(targetObject instanceof SourceParentOrder);
    SourceParentOrder parentOrder = (SourceParentOrder) targetObject;
    assertNotNull(parentOrder.getOrder());
    SourceOrder order = (SourceOrder) parentOrder.getOrder();
    assertNotNull(order.getAddress());
    assertTrue(order.getAddress() instanceof SourceAddress);
    SourceAddress address = (SourceAddress) order.getAddress();
    assertNull(address.getAddressLine1());
    assertNull(address.getAddressLine2());
    assertNull(address.getCity());
    assertNull(address.getState());
    assertNull(address.getZipCode());
    assertNotNull(order.getContact());
    assertTrue(order.getContact() instanceof SourceContact);
    SourceContact contact = (SourceContact) order.getContact();
    assertNull(contact.getFirstName());
    assertNull(contact.getLastName());
    assertNull(contact.getPhoneNumber());
    assertNull(contact.getZipCode());
}
Also used : SourceParentOrder(io.atlasmap.java.test.SourceParentOrder) SourceAddress(io.atlasmap.java.test.SourceAddress) JavaClass(io.atlasmap.java.v2.JavaClass) SourceOrder(io.atlasmap.java.test.SourceOrder) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test)

Example 5 with SourceAddress

use of io.atlasmap.java.test.SourceAddress in project atlasmap by atlasmap.

the class JavaConstructServiceComplexTest method testConstructSourceOrder.

@Test
public void testConstructSourceOrder() throws Exception {
    Object targetObject = constructService.constructClass(generateOrder("Source"), null);
    assertNotNull(targetObject);
    assertTrue(targetObject instanceof SourceOrder);
    SourceOrder order = (SourceOrder) targetObject;
    assertNotNull(order.getAddress());
    assertTrue(order.getAddress() instanceof SourceAddress);
    SourceAddress address = (SourceAddress) order.getAddress();
    assertNull(address.getAddressLine1());
    assertNull(address.getAddressLine2());
    assertNull(address.getCity());
    assertNull(address.getState());
    assertNull(address.getZipCode());
    assertNotNull(order.getContact());
    assertTrue(order.getContact() instanceof SourceContact);
    SourceContact contact = (SourceContact) order.getContact();
    assertNull(contact.getFirstName());
    assertNull(contact.getLastName());
    assertNull(contact.getPhoneNumber());
    assertNull(contact.getZipCode());
}
Also used : SourceAddress(io.atlasmap.java.test.SourceAddress) SourceOrder(io.atlasmap.java.test.SourceOrder) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test)

Aggregations

SourceAddress (io.atlasmap.java.test.SourceAddress)7 Test (org.junit.Test)7 SourceOrder (io.atlasmap.java.test.SourceOrder)6 AtlasPath (io.atlasmap.core.AtlasPath)3 SourceContact (io.atlasmap.java.test.SourceContact)3 SourceParentOrder (io.atlasmap.java.test.SourceParentOrder)2 BaseOrder (io.atlasmap.java.test.BaseOrder)1 SourceOrderArray (io.atlasmap.java.test.SourceOrderArray)1 SourceOrderList (io.atlasmap.java.test.SourceOrderList)1 JavaClass (io.atlasmap.java.v2.JavaClass)1 ArrayList (java.util.ArrayList)1