use of io.atlasmap.json.test.TargetFlatPrimitive 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.json.test.TargetFlatPrimitive in project atlasmap by atlasmap.
the class JavaJsonAutoConversionTest method executeMapping.
protected Object executeMapping(String fileName) throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File(fileName).toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass source = AtlasTestUtil.generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class);
session.setDefaultSourceDocument(source);
context.process(session);
assertFalse(session.hasErrors(), printAudit(session));
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
return targetObject;
}
use of io.atlasmap.json.test.TargetFlatPrimitive 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.json").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(session.hasErrors(), printAudit(session));
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("<?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, targetXml.toString());
}
use of io.atlasmap.json.test.TargetFlatPrimitive in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest method testProcessJavaJsonFlatPrimitiveUnrooted.
@Test
public void testProcessJavaJsonFlatPrimitiveUnrooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-flatprimitive-unrooted.json"));
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class));
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);
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
use of io.atlasmap.json.test.TargetFlatPrimitive in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest method testProcessJavaJsonBoxedFlatMappingPrimitiveRooted.
@Test
public void testProcessJavaJsonBoxedFlatMappingPrimitiveRooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-boxedflatprimitive-rooted.json"));
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(generateFlatPrimitiveClassBoxedPrimitiveFieldsBoxedValues(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.validateJsonFlatPrimitiveBoxedPrimitiveFields(targetObject);
}
Aggregations