use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaConstructServiceComplexArrayTest method testConstructTargetOrderArray.
@Test
public void testConstructTargetOrderArray() throws Exception {
Object targetObject = constructService.constructClass(generateOrderArray("Target"), null);
assertNotNull(targetObject);
assertTrue(targetObject instanceof TargetOrderArray);
TargetOrderArray orderArray = (TargetOrderArray) targetObject;
for (int i = 0; i < orderArray.getOrders().length; i++) {
TargetOrder order = (TargetOrder) orderArray.getOrders()[i];
assertNotNull(order);
assertNotNull(order.getAddress());
assertTrue(order.getAddress() instanceof TargetAddress);
TargetAddress address = (TargetAddress) order.getAddress();
assertNull(address.getAddressLine1());
assertNull(address.getAddressLine2());
assertNull(address.getCity());
assertNull(address.getState());
assertNull(address.getZipCode());
assertNotNull(order.getContact());
assertTrue(order.getContact() instanceof TargetContact);
TargetContact contact = (TargetContact) order.getContact();
assertNull(contact.getFirstName());
assertNull(contact.getLastName());
assertNull(contact.getPhoneNumber());
assertNull(contact.getZipCode());
}
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaMultiSourceTest method testProcessBasic.
@Test
public void testProcessBasic() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-multisource-basic.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
BaseAddress sourceAddress = AtlasTestUtil.generateAddress(SourceAddress.class);
session.setSourceDocument("con", sourceContact);
session.setSourceDocument("addr", sourceAddress);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
assertEquals("Ozzie", targetContact.getFirstName());
assertNull(targetContact.getLastName());
assertNull(targetContact.getPhoneNumber());
assertEquals("90210", targetContact.getZipCode());
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaSeparateTest method testProcessSeparateSkip.
@Test
public void testProcessSeparateSkip() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-skip.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie L. Smith Jr.");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
AtlasTestUtil.validateContact(targetContact);
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaSeparateTest method testProcessSeparateOutOfOrder.
@Test
public void testProcessSeparateOutOfOrder() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-outoforder.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie L. Smith Jr.");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
AtlasTestUtil.validateContact(targetContact);
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.
the class JavaJavaSeparateTest method testProcessSeparateNotEnoughSource.
@Test
public void testProcessSeparateNotEnoughSource() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-inputshort.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
assertNotNull(targetContact);
assertEquals("Ozzie", targetContact.getFirstName());
assertEquals(null, targetContact.getLastName());
assertTrue(session.hasWarns());
assertEquals("Separate returned fewer segments count=3 when targetField.path=/lastName requested index=3", session.getAudits().getAudit().get(0).getMessage());
}
Aggregations