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