use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlFlatMappingTest method testProcessXmlXmlFlatPrimitiveElementToAtributeNoMappedBoxedFieldsNS.
@Test
public void testProcessXmlXmlFlatPrimitiveElementToAtributeNoMappedBoxedFieldsNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-flatprimitive-elementToAttribute-noboxed-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 XmlXmlFlatMappingTest method testProcessXmlXmlBoxedFlatMappingPrimitiveElementToAttribute.
@Test
public void testProcessXmlXmlBoxedFlatMappingPrimitiveElementToAttribute() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-boxedflatprimitive-elementToAttribute.xml"));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-boxedflatprimitive-element.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><XmlFBPA boxedBooleanField=\"true\" boxedByteField=\"87\" boxedCharField=\"z\" boxedDoubleField=\"90000000.0\" boxedFloatField=\"70000000.0\" boxedIntField=\"5\" boxedLongField=\"20000\" boxedShortField=\"5\"/>", object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlXmlMultiSourceTest method testProcessBasic.
@Test
public void testProcessBasic() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-multisource-basic.xml").toURI());
AtlasSession session = context.createSession();
String sourceContact = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-contact-attribute.xml");
String sourceAddress = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-address-attribute.xml");
session.setSourceDocument("con", sourceContact);
session.setSourceDocument("addr", sourceAddress);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><Contact firstName=\"Ozzie\" zipCode=\"90210\"/>", object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JsonJsonMultiSourceTest method testProcessBasic.
@Test
public void testProcessBasic() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-multisource-basic.xml").toURI());
AtlasSession session = context.createSession();
String sourceContact = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-contact-unrooted.json");
String sourceAddress = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-address-unrooted.json");
session.setSourceDocument("con", sourceContact);
session.setSourceDocument("addr", sourceAddress);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
TargetContact targetContact = testMapper.readValue((String) object, TargetContact.class);
assertEquals("Ozzie", targetContact.getFirstName());
assertNull(targetContact.getLastName());
assertNull(targetContact.getPhoneNumber());
assertEquals("90210", targetContact.getZipCode());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JsonJsonMultiSourceTest method testProcessComplex.
@Test
public void testProcessComplex() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-multisource-complex.xml").toURI());
AtlasSession session = context.createSession();
String sourceContact = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-contact-unrooted.json");
String sourceAddress = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-address-unrooted.json");
session.setSourceDocument("con", sourceContact);
session.setSourceDocument("addr", sourceAddress);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
TargetOrder targetOrder = testMapper.readValue((String) object, TargetOrder.class);
AtlasTestUtil.validateJsonOrder(targetOrder);
}
Aggregations