use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectElementToAttribute.
@Test
public void testProcessXmlXmlComplexOrderAutodetectElementToAttribute() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-complex-order-autodetect-elementToAttribute.xml").toURI());
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-complex-order-autodetect-element.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><XmlOA orderId=\"8765309\"><Contact firstName=\"Ozzie\" lastName=\"Smith\" phoneNumber=\"5551212\" zipCode=\"81111\"/><Address addressLine1=\"123 Main St\" addressLine2=\"Suite 42b\" city=\"Anytown\" state=\"NY\" zipCode=\"90210\"/></XmlOA>", object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectAttributeToElementNS.
@Test
public void testProcessXmlXmlComplexOrderAutodetectAttributeToElementNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-complex-order-autodetect-attributeToElement-ns.xml").toURI());
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-complex-order-autodetect-attribute-ns.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
JAXBElement<XmlOrderElement> xmlOE = AtlasXmlTestHelper.unmarshal((String) object, XmlOrderElement.class);
AtlasTestUtil.validateXmlOrderElement(xmlOE.getValue());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class CamelAtlasmap14Test method test.
@Test
public void test() throws Exception {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/issue/camel-atlasmap-14-mapping.json");
AtlasMapping mapping = mappingService.loadMapping(url, AtlasMappingFormat.JSON);
AtlasContext context = DefaultAtlasContextFactory.getInstance().createContext(mapping);
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(generateTwitterStatus());
context.process(session);
assertFalse(TestHelper.printAudit(session), session.hasErrors());
Object output = session.getDefaultTargetDocument();
assertEquals(String.class, output.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode outJson = mapper.readTree((String) output);
assertNotNull(outJson.get("TwitterScreenName__c"));
assertEquals("bobvila1982", outJson.get("TwitterScreenName__c").asText());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class ConstantPropertyTest method test.
@Test
public void test() throws Exception {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/issue/constant-property-mapping.xml");
AtlasMapping mapping = mappingService.loadMapping(url, AtlasMappingFormat.XML);
AtlasContext context = DefaultAtlasContextFactory.getInstance().createContext(mapping);
AtlasSession session = context.createSession();
context.process(session);
assertFalse(TestHelper.printAudit(session), session.hasErrors());
TargetClass output = TargetClass.class.cast(session.getTargetDocument("io.atlasmap.core.issue.TargetClass"));
assertEquals("testValue", output.getTargetName());
assertNotEquals("testPath", output.getTargetFirstName());
assertEquals(777, output.getTargetInteger());
System.setProperty("testProp", "testProp-sysProp");
System.setProperty("PATH", "PATH-sysProp");
context.process(session);
assertFalse(TestHelper.printAudit(session), session.hasErrors());
output = TargetClass.class.cast(session.getTargetDocument("io.atlasmap.core.issue.TargetClass"));
assertEquals("testProp-sysProp", output.getTargetName());
assertEquals("PATH-sysProp", output.getTargetFirstName());
assertEquals(777, output.getTargetInteger());
session.getProperties().put("testProp", "testProp-runtimeProp");
session.getProperties().put("PATH", "PATH-runtimeProp");
context.process(session);
assertFalse(TestHelper.printAudit(session), session.hasErrors());
output = TargetClass.class.cast(session.getTargetDocument("io.atlasmap.core.issue.TargetClass"));
assertEquals("testProp-runtimeProp", output.getTargetName());
assertEquals("PATH-runtimeProp", output.getTargetFirstName());
assertEquals(777, output.getTargetInteger());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class OverloadedFieldActionsTest method testMappingDayOfWeekString.
@Test
public void testMappingDayOfWeekString() throws Exception {
AtlasContext context = atlasContextFactory.createContext(generateMappingDayOfWeek(String.class));
AtlasSession session = context.createSession();
SourceFlatPrimitiveClass src = new SourceFlatPrimitiveClass();
src.setBoxedStringField("mon");
session.setInput(src);
context.process(session);
Object tgt = session.getOutput();
assertNotNull(tgt);
assertTrue(tgt.getClass().isAssignableFrom(TargetFlatPrimitiveClass.class));
System.out.println(((TargetFlatPrimitiveClass) tgt).getBoxedStringField());
}
Aggregations