use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JsonJsonCollectionConversionTest method testProcessCollectionFromNonCollection.
@Test
public void testProcessCollectionFromNonCollection() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-collection-from-noncollection.xml").toURI());
// contact.firstName -> contact<>.name
String input = "{ \"contact\": { \"firstName\": \"name9\" } }";
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(input);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
String output = "{\"contact\":[{\"name\":\"name9\"}]}";
assertEquals(output, object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JsonJsonCollectionConversionTest method testProcessCollectionArraySimple.
@Test
public void testProcessCollectionArraySimple() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-collection-array-simple.xml").toURI());
// contact[].firstName -> contact[].name
String input = "{ \"contact\": [";
for (int i = 0; i < 3; i++) {
input += "{ \"firstName\": \"name" + i + "\"}";
input += (i == 2) ? "" : ",";
}
input += "] }";
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(input);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
String output = "{\"contact\":[";
for (int i = 0; i < 3; i++) {
output += "{\"name\":\"name" + i + "\"}";
output += (i == 2) ? "" : ",";
}
output += "]}";
assertEquals(output, object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JsonJsonComplexTest method testProcessJsonJsonComplexOrderAutodetectRooted.
@Test
public void testProcessJsonJsonComplexOrderAutodetectRooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-complex-order-autodetect-rooted.xml").toURI());
AtlasSession session = context.createSession();
String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-complex-order-autodetect-rooted.json");
session.setDefaultSourceDocument(source);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestRootedMapper testMapper = new AtlasJsonTestRootedMapper();
TargetOrder targetObject = testMapper.readValue((String) object, TargetOrder.class);
AtlasTestUtil.validateJsonOrder(targetObject);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlJavaFlatMappingTest method testProcessXmlJavaFlatPrimitiveElementNSDocumentWithoutNS.
@Test
// reference: [AT-420]
@Ignore
public void testProcessXmlJavaFlatPrimitiveElementNSDocumentWithoutNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-flatprimitive-element-ns-doc-wo-ns.xml"));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-flatprimitive-element.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class XmlJavaFlatMappingTest method testProcessXmlJavaFlatPrimitiveAttributeNS.
@Test
public void testProcessXmlJavaFlatPrimitiveAttributeNS() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-flatprimitive-attribute-ns.xml"));
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-flatprimitive-attribute-ns.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
}
Aggregations