use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class JavaJavaCollectionTest method testProcessCollectionList.
@Test
public void testProcessCollectionList() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-list.xml").toURI());
AtlasSession session = context.createSession();
BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
session.setDefaultSourceDocument(sourceOrder);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
assertEquals(20, object.getContactList().size());
for (int i = 0; i < 20; i++) {
TargetContact contact = object.getContactList().get(i);
if (i == 4 || i == 19) {
assertEquals("Ozzie", contact.getFirstName());
} else {
assertNull(contact);
}
}
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class JavaJavaCollectionTest method testProcessCollectionListSimple.
@Test
public void testProcessCollectionListSimple() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-list-simple.xml").toURI());
TargetTestClass input = new TargetTestClass();
input.setContactList(new LinkedList<>());
for (int i = 0; i < 5; i++) {
input.getContactList().add(new TargetContact());
input.getContactList().get(i).setFirstName("fname" + i);
}
AtlasSession session = context.createSession();
session.setSourceDocument("io.atlasmap.java.test.TargetTestClass", input);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
assertEquals(5, object.getContactList().size());
for (int i = 0; i < 5; i++) {
assertEquals(input.getContactList().get(i).getFirstName(), object.getContactList().get(i).getFirstName());
}
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class JavaJavaCollectionTest method testProcessCollectionPrimitive.
@Test
public void testProcessCollectionPrimitive() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-flatprimitive.xml").toURI());
SourceFlatPrimitiveClass source = new SourceFlatPrimitiveClass();
source.setBoxedStringField("fuga");
source.setBoxedStringArrayField(new String[] { "foo", "bar", "hoge", "fuga" });
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(source);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
TargetFlatPrimitiveClass target = (TargetFlatPrimitiveClass) session.getDefaultTargetDocument();
assertEquals("fuga", target.getBoxedStringField());
assertEquals(1, target.getBoxedStringArrayField().length);
assertEquals("fuga", target.getBoxedStringArrayField()[0]);
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class JavaJavaCollectionTest method testProcessCollectionArray.
@Test
public void testProcessCollectionArray() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-array.xml").toURI());
AtlasSession session = context.createSession();
BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
session.setDefaultSourceDocument(sourceOrder);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
assertEquals(20, object.getContactArray().length);
for (int i = 0; i < 20; i++) {
TargetContact contact = object.getContactArray()[i];
if (i == 6 || i == 19) {
assertEquals("Ozzie", contact.getFirstName());
} else {
assertNull(contact);
}
}
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class JavaJavaCombineTest method processCombineMapping.
protected AtlasSession processCombineMapping(String mappingFile, BaseContact sourceContact) throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File(mappingFile).toURI());
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
return session;
}
Aggregations