Search in sources :

Example 1 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 2 with BaseOrder

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

the class JavaJavaComplexTest method testProcessBasic.

@Test
public void testProcessBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-basic.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();
    assertEquals(TargetOrder.class.getName(), object.getClass().getName());
    TargetOrder targetOrder = (TargetOrder) object;
    assertEquals(new Integer(8765309), targetOrder.getOrderId());
}
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 3 with BaseOrder

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

the class JavaJavaComplexTest method testProcessComplexBasicNullContact.

@Test
public void testProcessComplexBasicNullContact() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-simple.xml").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    sourceOrder.setContact(null);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
    assertEquals(TargetContact.class.getName(), object.getContact().getClass().getName());
    assertNull(object.getContact().getFirstName());
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 4 with BaseOrder

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

the class JavaJavaComplexTest method testProcessComplexBasic.

@Test
public void testProcessComplexBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-simple.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());
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
    assertEquals(TargetContact.class.getName(), object.getContact().getClass().getName());
    assertEquals("Ozzie", object.getContact().getFirstName());
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 5 with BaseOrder

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

the class JavaJavaComplexTest method testProcessJavaJavaComplexAutoDetectFullActions.

@Test
public void testProcessJavaJavaComplexAutoDetectFullActions() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-autodetect-full-actions.xml"));
    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);
    // ensure our Uppercase action on first name did the right thing
    assertEquals("OZZIE", ((TargetOrder) object).getContact().getFirstName());
    assertEquals("smith", ((TargetOrder) object).getContact().getLastName());
    // set values to normalized pre-action-processing state so rest of validation
    // passes..
    ((TargetOrder) object).getContact().setFirstName("Ozzie");
    ((TargetOrder) object).getContact().setLastName("Smith");
    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)

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