use of io.atlasmap.java.test.TargetFlatPrimitiveClass in project atlasmap by atlasmap.
the class OverloadedFieldActionsTest method testMappingDayOfWeekInteger.
@Test
public void testMappingDayOfWeekInteger() throws Exception {
AtlasContext context = atlasContextFactory.createContext(generateMappingDayOfWeek(Integer.class));
AtlasSession session = context.createSession();
SourceFlatPrimitiveClass src = new SourceFlatPrimitiveClass();
src.setIntField(1);
session.setInput(src);
context.process(session);
Object tgt = session.getOutput();
assertNotNull(tgt);
assertTrue(tgt.getClass().isAssignableFrom(TargetFlatPrimitiveClass.class));
System.out.println(((TargetFlatPrimitiveClass) tgt).getBoxedStringField());
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass in project atlasmap by atlasmap.
the class DocumentJavaFieldWriterTest method testWritingPrimitiveArrays.
@Test
public void testWritingPrimitiveArrays() throws Exception {
addClassForFieldPath("/", TargetFlatPrimitiveClass.class);
addClassForFieldPath("/intArrayField[34]", int.class);
addClassForFieldPath("/boxedStringArrayField[312]", String.class);
write("/intArrayField[10]", 3425);
TargetFlatPrimitiveClass o = (TargetFlatPrimitiveClass) writer.getRootObject();
ensureNotNullAndClass(o, TargetFlatPrimitiveClass.class);
ensureNotNullAndClass(o.getIntArrayField(), int[].class);
assertEquals(11, o.getIntArrayField().length);
assertEquals(3425, o.getIntArrayField()[10]);
write("/boxedStringArrayField[10]", "boxedString");
ensureNotNullAndClass(o.getBoxedStringArrayField(), String[].class);
assertEquals(11, o.getBoxedStringArrayField().length);
for (int i = 0; i < 10; i++) {
System.out.println("Checking #" + i);
assertNull(o.getBoxedStringArrayField()[i]);
}
ensureNotNullAndClass(o.getBoxedStringArrayField()[10], String.class);
assertEquals("boxedString", o.getBoxedStringArrayField()[10]);
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass in project atlasmap by atlasmap.
the class DocumentJavaFieldWriterTest method testPrimitiveArrayLookup.
@Test
public void testPrimitiveArrayLookup() throws Exception {
addClassForFieldPath("/", TargetFlatPrimitiveClass.class);
write("/intArrayField[10]", 3425);
TargetFlatPrimitiveClass o = (TargetFlatPrimitiveClass) writer.getRootObject();
ensureNotNullAndClass(o, TargetFlatPrimitiveClass.class);
ensureNotNullAndClass(o.getIntArrayField(), int[].class);
assertEquals(11, o.getIntArrayField().length);
assertEquals(3425, o.getIntArrayField()[10]);
write("/boxedStringArrayField[10]", "boxedString");
ensureNotNullAndClass(o.getBoxedStringArrayField(), String[].class);
assertEquals(11, o.getBoxedStringArrayField().length);
for (int i = 0; i < 10; i++) {
System.out.println("Checking #" + i);
assertNull(o.getBoxedStringArrayField()[i]);
}
ensureNotNullAndClass(o.getBoxedStringArrayField()[10], String.class);
assertEquals("boxedString", o.getBoxedStringArrayField()[10]);
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues.
@Test
public void testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-flatprimitive.xml").toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass sourceClass = generateFlatPrimitiveClassPrimitiveFieldsBoxedValues(SourceFlatPrimitiveClass.class);
session.setDefaultSourceDocument(sourceClass);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
Validations validations = session.getValidations();
for (Validation v : validations.getValidation()) {
printValidation(v);
}
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass in project atlasmap by atlasmap.
the class JavaJavaFieldActionsTest method getTargetValue.
@Override
public Object getTargetValue(Object target, Class<?> targetClassExpected) {
System.out.println("Extracting target value from: " + target);
TargetFlatPrimitiveClass c = (TargetFlatPrimitiveClass) target;
Object result = c.getBoxedStringField();
if (this.targetField.getPath().equals("/boxedIntField")) {
result = c.getBoxedIntField();
}
System.out.println("Output value extracted: " + result);
return result;
}
Aggregations