Search in sources :

Example 11 with TargetFlatPrimitive

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

the class JavaJsonFlatMappingTest method testProcessJavaJsonBoxedFlatMappingPrimitiveUnrooted.

@Test
public void testProcessJavaJsonBoxedFlatMappingPrimitiveUnrooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-boxedflatprimitive-unrooted.json"));
    AtlasSession session = context.createSession();
    session.setDefaultSourceDocument(generateFlatPrimitiveClassBoxedPrimitiveFieldsBoxedValues(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.validateJsonFlatPrimitiveBoxedPrimitiveFields(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) SourceFlatPrimitiveClass(io.atlasmap.java.test.SourceFlatPrimitiveClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 12 with TargetFlatPrimitive

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

the class JavaJsonFlatMappingTest method testProcessJavaJsonFlatPrimitiveRooted.

@Test
public void testProcessJavaJsonFlatPrimitiveRooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-flatprimitive-rooted.json"));
    AtlasSession session = context.createSession();
    session.setDefaultSourceDocument(generateFlatPrimitiveClass(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.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) AtlasJsonTestRootedMapper(io.atlasmap.json.test.AtlasJsonTestRootedMapper) AtlasContext(io.atlasmap.api.AtlasContext) SourceFlatPrimitiveClass(io.atlasmap.java.test.SourceFlatPrimitiveClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 13 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(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);
    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)

Example 14 with TargetFlatPrimitive

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

the class JsonJsonAutoConversionTest method testProcessJsonJsonFlatFieldMappingAutoConversion3.

@Test
public void testProcessJsonJsonFlatFieldMappingAutoConversion3() throws Exception {
    TargetFlatPrimitive targetObject = executeMapping("src/test/resources/jsonToJson/atlasmapping-flatprimitive-unrooted-autoconversion-3.json");
    AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion3(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) Test(org.junit.jupiter.api.Test) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest)

Example 15 with TargetFlatPrimitive

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

the class JsonJsonAutoConversionTest method testProcessJsonJsonFlatFieldMappingAutoConversion1.

@Test
public void testProcessJsonJsonFlatFieldMappingAutoConversion1() throws Exception {
    TargetFlatPrimitive targetObject = executeMapping("src/test/resources/jsonToJson/atlasmapping-flatprimitive-unrooted-autoconversion-1.json");
    AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion1(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) Test(org.junit.jupiter.api.Test) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest)

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