use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlJsonFlatMappingTest method processXmlToJsonRooted.
protected void processXmlToJsonRooted(String mappingFile, String inputFile, boolean boxed) throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File(mappingFile));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString(inputFile);
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestRootedMapper testMapper = new AtlasJsonTestRootedMapper();
TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
if (boxed) {
AtlasTestUtil.validateJsonFlatPrimitiveBoxedPrimitiveFields(targetObject);
} else {
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlJsonFlatMappingTest method testProcessXmlJavaFlatPrimitiveElementNS.
@Test
public void testProcessXmlJavaFlatPrimitiveElementNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-flatprimitive-element-ns.xml"));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-flatprimitive-element-ns.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
// validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass)object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlJsonFlatMappingTest method testProcessXmlJavaBoxedFlatMappingPrimitiveElement.
@Test
public void testProcessXmlJavaBoxedFlatMappingPrimitiveElement() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-boxedflatprimitive-element.xml"));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-boxedflatprimitive-element.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
// validateFlatPrimitiveClassBoxedPrimitiveFields((TargetFlatPrimitiveClass)object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlJsonFlatMappingTest method processXmlToJsonUnrooted.
protected void processXmlToJsonUnrooted(String mappingFile, String inputFile, boolean boxed) throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File(mappingFile));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString(inputFile);
session.setDefaultSourceDocument(sourceXml);
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);
if (boxed) {
AtlasTestUtil.validateJsonFlatPrimitiveBoxedPrimitiveFields(targetObject);
} else {
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlJsonFlatMappingTest method testProcessXmlJavaBoxedFlatMappingPrimitiveElementNS.
@Test
public void testProcessXmlJavaBoxedFlatMappingPrimitiveElementNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-boxedflatprimitive-element-ns.xml"));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-boxedflatprimitive-element-ns.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
// validateFlatPrimitiveClassBoxedPrimitiveFields((TargetFlatPrimitiveClass)object);
}
Aggregations