use of io.atlasmap.java.test.BaseContact in project atlasmap by atlasmap.
the class JavaXmlCombineTest method testProcessCombineOutOfOrder.
@Test
public void testProcessCombineOutOfOrder() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/atlasmapping-combine-outoforder.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
JAXBElement<XmlContactAttribute> targetContact = AtlasXmlTestHelper.unmarshal((String) object, XmlContactAttribute.class);
assertEquals("Ozzie Smith 5551212 81111", targetContact.getValue().getFirstName());
assertNull(targetContact.getValue().getLastName());
assertNull(targetContact.getValue().getPhoneNumber());
assertNull(targetContact.getValue().getZipCode());
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.BaseContact in project atlasmap by atlasmap.
the class JavaXmlSeparateTest method testProcessSeparateSkip.
@Test
public void testProcessSeparateSkip() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/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);
assertTrue(object instanceof String);
JAXBElement<XmlContactAttribute> targetContact = AtlasXmlTestHelper.unmarshal((String) object, XmlContactAttribute.class);
AtlasTestUtil.validateXmlContactAttribute(targetContact.getValue());
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.BaseContact in project atlasmap by atlasmap.
the class JavaXmlSeparateTest method testProcessSeparateOutOfOrder.
@Test
public void testProcessSeparateOutOfOrder() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/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);
assertTrue(object instanceof String);
JAXBElement<XmlContactAttribute> targetContact = AtlasXmlTestHelper.unmarshal((String) object, XmlContactAttribute.class);
AtlasTestUtil.validateXmlContactAttribute(targetContact.getValue());
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.BaseContact in project atlasmap by atlasmap.
the class AtlasTestUtil method generateContact.
public static BaseContact generateContact(Class<? extends BaseContact> contactClass) throws Exception {
Class<?> targetClazz = AtlasTestUtil.class.getClassLoader().loadClass(contactClass.getName());
BaseContact newObject = (BaseContact) targetClazz.newInstance();
newObject.setFirstName("Ozzie");
newObject.setLastName("Smith");
newObject.setPhoneNumber("5551212");
newObject.setZipCode("81111");
return newObject;
}
use of io.atlasmap.java.test.BaseContact 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());
}
Aggregations