Search in sources :

Example 11 with BaseOrder

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

the class AtlasTestUtil method generateOrderListClass.

public static BaseOrderList generateOrderListClass(Class<? extends BaseOrderList> orderListClazz, Class<? extends BaseOrder> orderClazz, Class<? extends BaseAddress> addressClazz, Class<? extends BaseContact> contactClazz) throws Exception {
    Class<?> targetClazz = AtlasTestUtil.class.getClassLoader().loadClass(orderListClazz.getName());
    BaseOrderList orderList = (BaseOrderList) targetClazz.newInstance();
    orderList.setNumberOrders(5);
    orderList.setOrderBatchNumber(4123562);
    for (int i = 0; i < 5; i++) {
        BaseOrder baseOrder = generateOrderClass(orderClazz, addressClazz, contactClazz);
        baseOrder.setOrderId(i);
        if (orderList.getOrders() == null) {
            orderList.setOrders(new ArrayList<BaseOrder>());
        }
        orderList.getOrders().add(baseOrder);
    }
    return orderList;
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) BaseOrderList(io.atlasmap.java.test.BaseOrderList)

Example 12 with BaseOrder

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

the class AtlasTestUtil method generateOrderClass.

public static BaseOrder generateOrderClass(Class<? extends BaseOrder> orderClazz, Class<? extends BaseAddress> addressClazz, Class<? extends BaseContact> contactClazz) throws Exception {
    Class<?> targetClazz = AtlasTestUtil.class.getClassLoader().loadClass(orderClazz.getName());
    BaseOrder newObject = (BaseOrder) targetClazz.newInstance();
    newObject.setOrderId(8765309);
    newObject.setAddress(generateAddress(addressClazz));
    newObject.setContact(generateContact(contactClazz));
    return newObject;
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder)

Example 13 with BaseOrder

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

the class JavaJavaComplexTest method testProcessJavaJavaComplexAutoDetectFull.

@Test
public void testProcessJavaJavaComplexAutoDetectFull() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-autodetect-full.xml").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetOrder);
    AtlasTestUtil.validateOrder((TargetOrder) object);
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 14 with BaseOrder

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

the class JavaJavaComplexTest method testProcessJavaJavaComplexWithAbstractBasic.

@Test
public void testProcessJavaJavaComplexWithAbstractBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-abstract.xml").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetOrder);
    TargetOrder targetOrder = (TargetOrder) object;
    assertNotNull(targetOrder.getOrderId());
    assertEquals(new Integer(8765309), targetOrder.getOrderId());
    // Address should _not_ be populated
    assertNull(targetOrder.getAddress());
    // Contact should only have firstName populated
    assertNotNull(targetOrder.getContact());
    assertTrue(targetOrder.getContact() instanceof TargetContact);
    TargetContact targetContact = (TargetContact) targetOrder.getContact();
    assertNotNull(targetContact.getFirstName());
    assertEquals("Ozzie", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 15 with BaseOrder

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

the class JavaJsonComplexTest method testProcessJsonJavaComplexOrderAutodetectUnrooted.

@Test
public void testProcessJsonJavaComplexOrderAutodetectUnrooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-complex-order-autodetect-unrooted.xml").toURI());
    AtlasSession session = context.createSession();
    BaseOrder source = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(source);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    io.atlasmap.json.test.TargetOrder targetObject = testMapper.readValue((String) object, io.atlasmap.json.test.TargetOrder.class);
    AtlasTestUtil.validateJsonOrder(targetObject);
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Aggregations

BaseOrder (io.atlasmap.java.test.BaseOrder)19 Test (org.junit.Test)14 AtlasContext (io.atlasmap.api.AtlasContext)12 AtlasSession (io.atlasmap.api.AtlasSession)12 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)12 File (java.io.File)12 TargetTestClass (io.atlasmap.java.test.TargetTestClass)8 TargetContact (io.atlasmap.java.test.TargetContact)7 TargetOrder (io.atlasmap.java.test.TargetOrder)6 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)3 BaseOrderList (io.atlasmap.java.test.BaseOrderList)2 XmlOrderElement (io.atlasmap.xml.test.v2.XmlOrderElement)2 AtlasException (io.atlasmap.api.AtlasException)1 AtlasPath (io.atlasmap.core.AtlasPath)1 SourceAddress (io.atlasmap.java.test.SourceAddress)1 SourceOrder (io.atlasmap.java.test.SourceOrder)1 SourceOrderList (io.atlasmap.java.test.SourceOrderList)1 StateEnumClassLong (io.atlasmap.java.test.StateEnumClassLong)1 TargetAddress (io.atlasmap.java.test.TargetAddress)1 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)1