use of io.atlasmap.json.test.AtlasJsonTestUnrootedMapper 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.AtlasJsonTestUnrootedMapper in project atlasmap by atlasmap.
the class JavaJsonComplexTest method testProcessJsonJavaComplexOrderAutodetectUnrooted.
@Test
public void testProcessJsonJavaComplexOrderAutodetectUnrooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-complex-order-autodetect-unrooted.json").toURI());
AtlasSession session = context.createSession();
BaseOrder source = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
session.setDefaultSourceDocument(source);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetOrder targetObject = testMapper.readValue((String) object, io.atlasmap.json.test.TargetOrder.class);
AtlasTestUtil.validateJsonOrder(targetObject);
}
use of io.atlasmap.json.test.AtlasJsonTestUnrootedMapper in project atlasmap by atlasmap.
the class JavaJsonSeparateTest method testProcessSeparateSimple.
@Test
public void testProcessSeparateSimple() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-separate-simple.json").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Ozzie Smith");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
AtlasTestUtil.validateJsonContact(targetContact);
assertFalse(session.hasErrors());
}
use of io.atlasmap.json.test.AtlasJsonTestUnrootedMapper in project atlasmap by atlasmap.
the class JsonJsonAutoConversionTest method executeMapping.
protected TargetFlatPrimitive executeMapping(String fileName) throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File(fileName).toURI());
AtlasSession session = context.createSession();
String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-flatprimitive-unrooted-autoconversion.json");
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();
return testMapper.readValue((String) object, TargetFlatPrimitive.class);
}
use of io.atlasmap.json.test.AtlasJsonTestUnrootedMapper 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);
}
}
Aggregations