use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaCollectionTest method testProcessCollectionToNonCollection.
@Test
public void testProcessCollectionToNonCollection() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-to-noncollection.xml").toURI());
TargetTestClass input = new TargetTestClass();
input.setContactList(new LinkedList<>());
for (int i = 0; i < 5; i++) {
input.getContactList().add(new TargetContact());
input.getContactList().get(i).setFirstName("fname" + i);
}
AtlasSession session = context.createSession();
session.setSourceDocument("io.atlasmap.java.test.TargetTestClass", input);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
assertNull(object.getContactArray());
assertNull(object.getContactList());
assertEquals("fname4", object.getContact().getFirstName());
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaCombineTest method testProcessCombineNullInput.
@Test
public void testProcessCombineNullInput() throws Exception {
BaseContact source = AtlasTestUtil.generateContact(SourceContact.class);
source.setLastName(null);
AtlasSession session = processCombineMapping("src/test/resources/javaToJava/atlasmapping-combine-inputnull.xml", source);
TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
assertNotNull(targetContact);
assertEquals("Ozzie 5551212 81111", targetContact.getFirstName());
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaCombineTest method testProcessCombineOutOfOrder.
@Test
public void testProcessCombineOutOfOrder() throws Exception {
AtlasSession session = processCombineMapping("src/test/resources/javaToJava/atlasmapping-combine-outoforder.xml", AtlasTestUtil.generateContact(SourceContact.class));
TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
assertEquals("Ozzie Smith 5551212 81111", targetContact.getFirstName());
assertNull(targetContact.getLastName());
assertNull(targetContact.getPhoneNumber());
assertNull(targetContact.getZipCode());
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaCombineTest method testProcessCombineSkip.
@Test
public void testProcessCombineSkip() throws Exception {
AtlasSession session = processCombineMapping("src/test/resources/javaToJava/atlasmapping-combine-skip.xml", AtlasTestUtil.generateContact(SourceContact.class));
TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
assertEquals("Ozzie Smith 5551212 81111", targetContact.getFirstName());
assertNull(targetContact.getLastName());
assertNull(targetContact.getPhoneNumber());
assertNull(targetContact.getZipCode());
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.TargetContact 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());
}
Aggregations