Search in sources :

Example 1 with TargetOrder

use of io.atlasmap.json.test.TargetOrder in project atlasmap by atlasmap.

the class JsonJsonComplexTest method testProcessJsonJsonComplexOrderAutodetectUnrooted.

@Test
public void testProcessJsonJsonComplexOrderAutodetectUnrooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-complex-order-autodetect-unrooted.xml").toURI());
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-complex-order-autodetect-unrooted.json");
    session.setDefaultSourceDocument(source);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetOrder targetObject = testMapper.readValue((String) object, TargetOrder.class);
    AtlasTestUtil.validateJsonOrder(targetObject);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) TargetOrder(io.atlasmap.json.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 2 with TargetOrder

use of io.atlasmap.json.test.TargetOrder 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);
}
Also used : AtlasJsonTestRootedMapper(io.atlasmap.json.test.AtlasJsonTestRootedMapper) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.json.test.TargetOrder) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession)

Example 3 with TargetOrder

use of io.atlasmap.json.test.TargetOrder in project atlasmap by atlasmap.

the class JsonJsonMultiSourceTest method testProcessComplex.

@Test
public void testProcessComplex() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-multisource-complex.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceContact = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-contact-unrooted.json");
    String sourceAddress = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-address-unrooted.json");
    session.setSourceDocument("con", sourceContact);
    session.setSourceDocument("addr", sourceAddress);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetOrder targetOrder = testMapper.readValue((String) object, TargetOrder.class);
    AtlasTestUtil.validateJsonOrder(targetOrder);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) TargetOrder(io.atlasmap.json.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 4 with TargetOrder

use of io.atlasmap.json.test.TargetOrder 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);
}
Also used : AtlasJsonTestRootedMapper(io.atlasmap.json.test.AtlasJsonTestRootedMapper) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.json.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Aggregations

AtlasContext (io.atlasmap.api.AtlasContext)4 AtlasSession (io.atlasmap.api.AtlasSession)4 TargetOrder (io.atlasmap.json.test.TargetOrder)4 File (java.io.File)4 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)3 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)3 Test (org.junit.Test)3 AtlasJsonTestRootedMapper (io.atlasmap.json.test.AtlasJsonTestRootedMapper)2