Search in sources :

Example 6 with TargetFlatPrimitive

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

Example 7 with TargetFlatPrimitive

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

the class JsonJsonFlatMappingTest method testProcessJsonJsonBoxedFlatMappingPrimitiveUnrooted.

@Test
public void testProcessJsonJsonBoxedFlatMappingPrimitiveUnrooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-boxedflatprimitive-unrooted.xml"));
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-boxedflatprimitive-unrooted.json");
    session.setDefaultSourceDocument(source);
    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.validateJsonFlatPrimitiveBoxedPrimitiveFields(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 8 with TargetFlatPrimitive

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

Example 9 with TargetFlatPrimitive

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.xml").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(printAudit(session), session.hasErrors());
    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(targetXml.toString(), "<?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);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 10 with TargetFlatPrimitive

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

the class XmlJsonAutoConversionTest method processXmlJsonFlatMappingAutoConversion.

protected void processXmlJsonFlatMappingAutoConversion(String mappingFile, String inputFile, int num) throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File(mappingFile).toURI());
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString(inputFile);
    session.setDefaultSourceDocument(source);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
    switch(num) {
        case 1:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion1(targetObject);
            break;
        case 2:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion2(targetObject);
            break;
        case 3:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion3(targetObject);
            break;
        case 4:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion4(targetObject);
            break;
        case 5:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion5(targetObject);
            break;
        case 6:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion6(targetObject);
            break;
        case 7:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion7(targetObject);
            break;
        default:
            fail("Unexpected number: " + num);
    }
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession)

Aggregations

TargetFlatPrimitive (io.atlasmap.json.test.TargetFlatPrimitive)40 AtlasContext (io.atlasmap.api.AtlasContext)26 AtlasSession (io.atlasmap.api.AtlasSession)26 File (java.io.File)26 AtlasMappingBaseTest (io.atlasmap.itests.reference.AtlasMappingBaseTest)16 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)16 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)16 Test (org.junit.Test)16 Test (org.junit.jupiter.api.Test)16 AtlasJsonTestRootedMapper (io.atlasmap.json.test.AtlasJsonTestRootedMapper)10 SourceFlatPrimitiveClass (io.atlasmap.java.test.SourceFlatPrimitiveClass)8 BaseFlatPrimitiveClass (io.atlasmap.java.test.BaseFlatPrimitiveClass)4 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)2