use of io.atlasmap.xml.test.v2.XmlContactAttribute 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());
}
use of io.atlasmap.xml.test.v2.XmlContactAttribute 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.xml.test.v2.XmlContactAttribute 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.xml.test.v2.XmlContactAttribute 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.xml.test.v2.XmlContactAttribute in project atlasmap by atlasmap.
the class AtlasMapMultiDocsTest method test.
@Test
@DirtiesContext
public void test() throws Exception {
result.setExpectedCount(1);
Map<String, Message> sourceMap = new HashMap<>();
SourceContact javaSource = new SourceContact();
javaSource.setFirstName("JavaFirstName");
javaSource.setLastName("JavaLastName");
javaSource.setPhoneNumber("JavaPhoneNumber");
javaSource.setZipCode("JavaZipCode");
Message msg = new DefaultMessage(camelContext);
msg.setBody(javaSource);
sourceMap.put("DOCID:JAVA:CONTACT:S", msg);
msg = new DefaultMessage(camelContext);
msg.setBody(JSON_SOURCE);
sourceMap.put("DOCID:JSON:CONTACT:S", msg);
msg = new DefaultMessage(camelContext);
msg.setBody(XML_SOURCE);
sourceMap.put("DOCID:XML:CONTACT:S", msg);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBodyAndProperty("direct:start", null, "CAPTURED_OUT_MESSAGES_MAP", sourceMap);
MockEndpoint.assertIsSatisfied(camelContext);
Exchange exchange = result.getExchanges().get(0);
Map<?, ?> targetMap = exchange.getProperty(AtlasConstants.ATLAS_TARGET_MAP, Map.class);
TargetContact javaTarget = (TargetContact) targetMap.get("DOCID:JAVA:CONTACT:T");
assertEquals("JavaFirstName", javaTarget.getFirstName());
assertEquals("XmlLastName", javaTarget.getLastName());
assertEquals("JsonPhoneNumber", javaTarget.getPhoneNumber());
String jsonTarget = (String) targetMap.get("DOCID:JSON:CONTACT:T");
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonTargetNode = mapper.readTree(jsonTarget);
assertEquals("JsonFirstName", jsonTargetNode.get("firstName").asText());
assertEquals("JavaLastName", jsonTargetNode.get("lastName").asText());
assertEquals("XmlPhoneNumber", jsonTargetNode.get("phoneNumber").asText());
String xmlTarget = (String) targetMap.get("DOCID:XML:CONTACT:T");
JAXBElement<XmlContactAttribute> xmlTargetJaxb = AtlasXmlTestHelper.unmarshal(xmlTarget, XmlContactAttribute.class);
XmlContactAttribute xmlTargetObj = xmlTargetJaxb.getValue();
assertEquals("XmlFirstName", xmlTargetObj.getFirstName());
assertEquals("JsonLastName", xmlTargetObj.getLastName());
assertEquals("JavaPhoneNumber", xmlTargetObj.getPhoneNumber());
}
Aggregations