Search in sources :

Example 1 with TargetFlatPrimitive

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

the class JavaJsonFlatMappingTest method testProcessJavaJsonFlatPrimitiveUnrooted.

@Test
public void testProcessJavaJsonFlatPrimitiveUnrooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-flatprimitive-unrooted.xml"));
    AtlasSession session = context.createSession();
    session.setDefaultSourceDocument(generateFlatPrimitiveClass(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.validateJsonFlatPrimitivePrimitiveFields(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.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 2 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.xml"));
    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.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 3 with TargetFlatPrimitive

use of io.atlasmap.json.test.TargetFlatPrimitive 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(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);
    return targetObject;
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) 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)

Example 4 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.xml");
    AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion1(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 5 with TargetFlatPrimitive

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

the class JsonJsonAutoConversionTest method testProcessJsonJsonFlatFieldMappingAutoConversion4.

@Test
public void testProcessJsonJsonFlatFieldMappingAutoConversion4() throws Exception {
    TargetFlatPrimitive targetObject = executeMapping("src/test/resources/jsonToJson/atlasmapping-flatprimitive-unrooted-autoconversion-4.xml");
    AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion4(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.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