use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class MultidocFlatMappingTest method testProcessJavaJavaFlatFieldMapping.
@Test
public void testProcessJavaJavaFlatFieldMapping() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/multidoc/atlasmapping-flatprimitive.xml").toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass sourceJava = generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class);
session.setSourceDocument("SourceJava", sourceJava);
String sourceJson = AtlasTestUtil.loadFileAsString("src/test/resources/multidoc/atlas-json-flatprimitive-unrooted.json");
session.setSourceDocument("SourceJson", sourceJson);
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/multidoc/atlas-xml-flatprimitive-attribute.xml");
session.setSourceDocument("SourceXml", sourceXml);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object targetJava = session.getTargetDocument("TargetJava");
assertNotNull(targetJava);
assertTrue(targetJava instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) targetJava);
Object targetJson = session.getTargetDocument("TargetJson");
assertNotNull(targetJson);
assertTrue(targetJson instanceof String);
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
TargetFlatPrimitive targetObject = testMapper.readValue((String) targetJson, TargetFlatPrimitive.class);
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
Object targetXml = session.getTargetDocument("TargetXml");
assertNotNull(targetXml);
assertTrue(targetXml instanceof String);
assertEquals(targetXml.toString(), "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><XmlFPA booleanField=\"false\" byteField=\"99\" charField=\"a\" doubleField=\"5.0E7\" floatField=\"4.0E7\" intField=\"2\" longField=\"30000\" shortField=\"1\"/>", targetXml);
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class XmlJavaCombineTest method testProcessCombineSkip.
@Test
public void testProcessCombineSkip() throws Exception {
AtlasSession session = processCombineMapping("src/test/resources/xmlToJava/atlasmapping-combine-skip.xml", new String(Files.readAllBytes(Paths.get("src/test/resources/xmlToJava/atlas-xml-combine.xml"))));
TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
assertEquals("Ozzie Smith 5551212 81111", targetContact.getFirstName());
assertNull(targetContact.getLastName());
assertNull(targetContact.getPhoneNumber());
assertNull(targetContact.getZipCode());
assertFalse(session.hasErrors());
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class XmlJavaCombineTest method testProcessCombineSimple.
@Test
public void testProcessCombineSimple() throws Exception {
AtlasSession session = processCombineMapping("src/test/resources/xmlToJava/atlasmapping-combine-simple.xml", new String(Files.readAllBytes(Paths.get("src/test/resources/xmlToJava/atlas-xml-combine.xml"))));
TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
assertEquals("Ozzie Smith 5551212 81111", targetContact.getFirstName());
assertNull(targetContact.getLastName());
assertNull(targetContact.getPhoneNumber());
assertNull(targetContact.getZipCode());
assertFalse(session.hasErrors());
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class XmlJavaComplexTest method testProcessXmlJavaComplexOrderAutodetectAttributeNS.
@Test
public void testProcessXmlJavaComplexOrderAutodetectAttributeNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-complex-order-autodetect-attribute-ns.xml").toURI());
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-complex-order-autodetect-attribute-ns.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetOrder);
AtlasTestUtil.validateOrder((TargetOrder) object);
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class XmlJavaComplexTest method testProcessXmlJavaComplexOrderAutodetectElement.
@Test
public void testProcessXmlJavaComplexOrderAutodetectElement() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-complex-order-autodetect-element.xml").toURI());
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-complex-order-autodetect-element.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetOrder);
AtlasTestUtil.validateOrder((TargetOrder) object);
}
Aggregations