use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.
the class MultiplicityTransformationTest method testConcatenateTypes.
@Test
public void testConcatenateTypes() throws Exception {
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/atlasmapping-multiplicity-transformation-concatenate-types.json");
AtlasContext context = DefaultAtlasContextFactory.getInstance().createContext(url.toURI());
AtlasSession session = context.createSession();
TargetTestClass source = new TargetTestClass();
source.setCreated(new java.util.Date());
TargetFlatPrimitiveClass primitives = new TargetFlatPrimitiveClass();
primitives.setBoxedStringField("boxedString");
primitives.setCharField('c');
primitives.setIntField(1);
primitives.setFloatField(1.3f);
primitives.setLongField(2L);
primitives.setShortField((short) 2);
primitives.setDoubleField(3.1d);
primitives.setBoxedCharField(Character.valueOf('c'));
primitives.setBoxedIntField(Integer.valueOf(1));
primitives.setBoxedFloatField(Float.valueOf(1.3f));
primitives.setBoxedLongField(Long.valueOf(2L));
primitives.setBoxedShortField(Short.valueOf((short) 2));
primitives.setBoxedDoubleField(Double.valueOf(3.1d));
source.setPrimitives(primitives);
session.setSourceDocument("io.atlasmap.java.test.TargetTestClass", source);
context.process(session);
assertFalse(session.hasErrors(), TestHelper.printAudit(session));
Object output = session.getTargetDocument("io.atlasmap.java.test.TargetTestClass");
assertEquals(TargetTestClass.class, output.getClass());
TargetTestClass target = TargetTestClass.class.cast(output);
assertEquals(14, target.getFullAddress().split(" ").length, "[" + target.getFullAddress() + "]");
}
use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.
the class JavaJavaComplexTest method testProcessComplexBasic.
@Test
public void testProcessComplexBasic() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-simple.json").toURI());
AtlasSession session = context.createSession();
BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
session.setDefaultSourceDocument(sourceOrder);
context.process(session);
assertFalse(session.hasErrors(), printAudit(session));
TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
assertEquals(TargetContact.class.getName(), object.getContact().getClass().getName());
assertEquals("Ozzie", object.getContact().getFirstName());
}
use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.
the class JavaJavaComplexTest method testProcessComplexBasicNullContact.
@Test
public void testProcessComplexBasicNullContact() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-simple.json").toURI());
AtlasSession session = context.createSession();
BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
sourceOrder.setContact(null);
session.setDefaultSourceDocument(sourceOrder);
context.process(session);
assertFalse(session.hasErrors(), printAudit(session));
TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
// Lazy instantiation will not istantiate target class if source class is null (Java to Java)
assertNull(object.getContact());
}
use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.
the class JavaJavaCollectionTest method testProcessCollectionListEmpty.
@Test
public void testProcessCollectionListEmpty() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-list-empty.json").toURI());
AtlasSession session = context.createSession();
TargetTestClass source = new TargetTestClass();
session.setDefaultSourceDocument(source);
context.process(session);
assertFalse(session.hasErrors(), printAudit(session));
TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
assertEquals(0, object.getContactList().size());
}
use of io.atlasmap.java.test.TargetTestClass 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.json").toURI());
AtlasSession session = context.createSession();
BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
session.setDefaultSourceDocument(sourceOrder);
context.process(session);
assertFalse(session.hasErrors(), printAudit(session));
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);
}
}
}
Aggregations