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;
}
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());
}
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());
}
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());
}
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);
}
Aggregations