use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlCollectionConverstionTest method testProcessCollectionToNonCollection.
@Test
public void testProcessCollectionToNonCollection() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-collection-to-noncollection.xml").toURI());
// contact<>.firstName -> contact.name
String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
input += "<XmlOA>";
for (int i = 0; i < 3; i++) {
input += "<contact><firstName>name" + i + "</firstName></contact>";
}
input += "</XmlOA>";
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(input);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
String output = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>";
output += "<XmlOA>";
output += "<contact><name>name2</name></contact>";
output += "</XmlOA>";
assertEquals(output, object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectAttributeToElement.
@Test
public void testProcessXmlXmlComplexOrderAutodetectAttributeToElement() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-complex-order-autodetect-attributeToElement.xml").toURI());
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-complex-order-autodetect-attribute.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\"?><XmlOE><orderId>8765309</orderId><Contact><firstName>Ozzie</firstName><lastName>Smith</lastName><phoneNumber>5551212</phoneNumber><zipCode>81111</zipCode></Contact><Address><addressLine1>123 Main St</addressLine1><addressLine2>Suite 42b</addressLine2><city>Anytown</city><state>NY</state><zipCode>90210</zipCode></Address></XmlOE>", object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectElementToAttributeNS.
@Test
public void testProcessXmlXmlComplexOrderAutodetectElementToAttributeNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-complex-order-autodetect-elementToAttribute-ns.xml").toURI());
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-complex-order-autodetect-element-ns.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
JAXBElement<XmlOrderAttribute> xmlOA = AtlasXmlTestHelper.unmarshal((String) object, XmlOrderAttribute.class);
AtlasTestUtil.validateXmlOrderAttribute(xmlOA.getValue());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlFlatMappingTest method testProcessXmlXmlFlatPrimitiveElementToAttributeNS.
@Test
public void testProcessXmlXmlFlatPrimitiveElementToAttributeNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-flatprimitive-elementToAttribute-ns.xml"));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-flatprimitive-element-ns.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
JAXBElement<XmlFlatPrimitiveAttribute> xmlFPA = AtlasXmlTestHelper.unmarshal((String) object, XmlFlatPrimitiveAttribute.class);
AtlasTestUtil.validateXmlFlatPrimitiveAttribute(xmlFPA.getValue());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JsonJsonFlatMappingTest method testProcessJsonJsonFlatPrimitiveUnrooted.
@Test
public void testProcessJsonJsonFlatPrimitiveUnrooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-flatprimitive-unrooted.xml"));
AtlasSession session = context.createSession();
String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-flatprimitive-unrooted.json");
session.setDefaultSourceDocument(source);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
Aggregations