use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class XmlXmlCollectionConverstionTest method testProcessCollectionFromNonCollection.
@Test
public void testProcessCollectionFromNonCollection() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-collection-from-noncollection.xml").toURI());
// contact.firstName -> contact<>.name
String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
input += "<XmlOA>";
input += "<contact><firstName>name76</firstName></contact>";
input += "</XmlOA>";
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(input);
context.process(session);
String output = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>";
output += "<XmlOA>";
output += "<contact><name>name76</name></contact>";
output += "</XmlOA>";
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
assertEquals(output, object);
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class XmlXmlCollectionConverstionTest method testProcessCollectionArraySimple.
@Test
public void testProcessCollectionArraySimple() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-collection-array-simple.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>";
for (int i = 0; i < 3; i++) {
output += "<contact><name>name" + i + "</name></contact>";
}
output += "</XmlOA>";
assertEquals(output, object);
}
use of io.atlasmap.api.AtlasSession 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.AtlasSession 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.AtlasSession 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());
}
Aggregations