use of io.atlasmap.java.test.BaseContact in project atlasmap by atlasmap.
the class JavaJsonSeparateTest method testProcessSeparateNotEnoughSource.
@Test
public void testProcessSeparateNotEnoughSource() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/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);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
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());
}
use of io.atlasmap.java.test.BaseContact in project atlasmap by atlasmap.
the class JavaJsonSeparateTest method testProcessSeparateOutOfOrder.
@Test
public void testProcessSeparateOutOfOrder() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/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);
AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
AtlasTestUtil.validateJsonContact(targetContact);
assertFalse(session.hasErrors());
}
use of io.atlasmap.java.test.BaseContact 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());
}
use of io.atlasmap.java.test.BaseContact in project atlasmap by atlasmap.
the class JavaJsonCombineTest method testProcessCombineOutOfOrder.
@Test
public void testProcessCombineOutOfOrder() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-combine-outoforder.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
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.BaseContact in project atlasmap by atlasmap.
the class JavaXmlCombineTest method testProcessCombineSimple.
@Test
public void testProcessCombineSimple() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/atlasmapping-combine-simple.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());
}
Aggregations