Search in sources :

Example 16 with AtlasJsonTestUnrootedMapper

use of io.atlasmap.json.test.AtlasJsonTestUnrootedMapper 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 17 with AtlasJsonTestUnrootedMapper

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

the class JsonJsonFlatMappingTest method testProcessJsonJsonFlatPrimitiveUnrooted.

@Test
public void testProcessJsonJsonFlatPrimitiveUnrooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-flatprimitive-unrooted.xml"));
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-flatprimitive-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.validateJsonFlatPrimitivePrimitiveFields(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 18 with AtlasJsonTestUnrootedMapper

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

the class XmlJsonFlatMappingTest method processXmlToJsonUnrooted.

protected void processXmlToJsonUnrooted(String mappingFile, String inputFile, boolean boxed) throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File(mappingFile));
    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);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
    if (boxed) {
        AtlasTestUtil.validateJsonFlatPrimitiveBoxedPrimitiveFields(targetObject);
    } else {
        AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(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)

Example 19 with AtlasJsonTestUnrootedMapper

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

the class JavaJsonCombineTest method testProcessCombineNullInput.

@Test
public void testProcessCombineNullInput() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-combine-inputnull.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setLastName(null);
    session.setDefaultSourceDocument(sourceContact);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
    io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
    assertNotNull(targetContact);
    assertEquals("Ozzie  5551212 81111", targetContact.getFirstName());
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 20 with AtlasJsonTestUnrootedMapper

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

the class JavaJsonCombineTest method testProcessCombineSimple.

@Test
public void testProcessCombineSimple() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-combine-simple.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    session.setDefaultSourceDocument(sourceContact);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
    io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
    assertEquals("Ozzie    Smith   5551212                                                                                            81111", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Aggregations

AtlasContext (io.atlasmap.api.AtlasContext)25 AtlasSession (io.atlasmap.api.AtlasSession)25 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)25 File (java.io.File)25 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)20 Test (org.junit.Test)20 BaseContact (io.atlasmap.java.test.BaseContact)9 TargetFlatPrimitive (io.atlasmap.json.test.TargetFlatPrimitive)8 BaseOrder (io.atlasmap.java.test.BaseOrder)3 TargetOrder (io.atlasmap.json.test.TargetOrder)3 BaseFlatPrimitiveClass (io.atlasmap.java.test.BaseFlatPrimitiveClass)2 SourceFlatPrimitiveClass (io.atlasmap.java.test.SourceFlatPrimitiveClass)2 TargetTestClass (io.atlasmap.java.test.TargetTestClass)2 XmlOrderElement (io.atlasmap.xml.test.v2.XmlOrderElement)2 TargetContact (io.atlasmap.java.test.TargetContact)1 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)1 AtlasJsonTestRootedMapper (io.atlasmap.json.test.AtlasJsonTestRootedMapper)1 TargetContact (io.atlasmap.json.test.TargetContact)1