use of io.atlasmap.json.test.AtlasJsonTestRootedMapper in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest method testProcessJavaJsonFlatPrimitiveRooted.
@Test
public void testProcessJavaJsonFlatPrimitiveRooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-flatprimitive-rooted.xml"));
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class));
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);
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
use of io.atlasmap.json.test.AtlasJsonTestRootedMapper in project atlasmap by atlasmap.
the class JsonJsonFlatMappingTest method testProcessJsonJsonBoxedFlatMappingPrimitiveRooted.
@Test
public void testProcessJsonJsonBoxedFlatMappingPrimitiveRooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-boxedflatprimitive-rooted.xml"));
AtlasSession session = context.createSession();
String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-boxedflatprimitive-rooted.json");
session.setDefaultSourceDocument(source);
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);
AtlasTestUtil.validateJsonFlatPrimitiveBoxedPrimitiveFields(targetObject);
}
use of io.atlasmap.json.test.AtlasJsonTestRootedMapper in project atlasmap by atlasmap.
the class JsonJsonFlatMappingTest method testProcessJsonJsonFlatPrimitiveRooted.
@Test
public void testProcessJsonJsonFlatPrimitiveRooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-flatprimitive-rooted.xml"));
AtlasSession session = context.createSession();
String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-flatprimitive-rooted.json");
session.setDefaultSourceDocument(source);
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);
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
use of io.atlasmap.json.test.AtlasJsonTestRootedMapper in project atlasmap by atlasmap.
the class XmlJsonComplexTest method processXmlToJsonOrder.
protected void processXmlToJsonOrder(String mappingFile, String inputFile, boolean rooted) throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File(mappingFile).toURI());
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);
TargetOrder targetObject = null;
if (rooted) {
AtlasJsonTestRootedMapper testMapper = new AtlasJsonTestRootedMapper();
targetObject = testMapper.readValue((String) object, TargetOrder.class);
} else {
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
targetObject = testMapper.readValue((String) object, TargetOrder.class);
}
AtlasTestUtil.validateJsonOrder(targetObject);
}
use of io.atlasmap.json.test.AtlasJsonTestRootedMapper 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);
}
}
Aggregations