Search in sources :

Example 1 with TargetFlatPrimitiveClass

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());
}
Also used : TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) AtlasContext(io.atlasmap.api.AtlasContext) SourceFlatPrimitiveClass(io.atlasmap.java.test.SourceFlatPrimitiveClass) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test)

Example 2 with TargetFlatPrimitiveClass

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]);
}
Also used : TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) Test(org.junit.Test)

Example 3 with TargetFlatPrimitiveClass

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]);
}
Also used : TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) Test(org.junit.Test)

Example 4 with TargetFlatPrimitiveClass

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);
    }
}
Also used : Validation(io.atlasmap.v2.Validation) Validations(io.atlasmap.v2.Validations) TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) AtlasContext(io.atlasmap.api.AtlasContext) BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 5 with TargetFlatPrimitiveClass

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;
}
Also used : TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass)

Aggregations

TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)30 AtlasContext (io.atlasmap.api.AtlasContext)24 AtlasSession (io.atlasmap.api.AtlasSession)24 File (java.io.File)22 Test (org.junit.Test)22 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)18 BaseFlatPrimitiveClass (io.atlasmap.java.test.BaseFlatPrimitiveClass)6 SourceFlatPrimitiveClass (io.atlasmap.java.test.SourceFlatPrimitiveClass)3 AtlasException (io.atlasmap.api.AtlasException)2 TargetAddress (io.atlasmap.java.test.TargetAddress)2 TargetOrder (io.atlasmap.java.test.TargetOrder)2 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)2 TargetTestClass (io.atlasmap.java.test.TargetTestClass)2 TestListOrders (io.atlasmap.java.test.TestListOrders)2 BaseOrder (io.atlasmap.java.test.BaseOrder)1 StateEnumClassLong (io.atlasmap.java.test.StateEnumClassLong)1 TargetContact (io.atlasmap.java.test.TargetContact)1 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)1 TargetFlatPrimitive (io.atlasmap.json.test.TargetFlatPrimitive)1 Validation (io.atlasmap.v2.Validation)1