Search in sources :

Example 1 with TargetContact

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

the class JsonJsonMultiSourceTest method testProcessBasic.

@Test
public void testProcessBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-multisource-basic.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);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetContact targetContact = testMapper.readValue((String) object, TargetContact.class);
    assertEquals("Ozzie", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertEquals("90210", targetContact.getZipCode());
}
Also used : TargetContact(io.atlasmap.json.test.TargetContact) 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)1 AtlasSession (io.atlasmap.api.AtlasSession)1 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)1 TargetContact (io.atlasmap.json.test.TargetContact)1 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)1 File (java.io.File)1 Test (org.junit.Test)1