Search in sources :

Example 16 with BaseFlatPrimitiveClass

use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.

the class JavaJsonFlatMappingTest method generateFlatPrimitiveClass.

protected BaseFlatPrimitiveClass generateFlatPrimitiveClass(Class<? extends BaseFlatPrimitiveClass> clazz) throws Exception {
    Class<?> targetClazz = this.getClass().getClassLoader().loadClass(clazz.getName());
    BaseFlatPrimitiveClass newObject = (BaseFlatPrimitiveClass) targetClazz.newInstance();
    newObject.setBooleanField(false);
    newObject.setByteField((byte) 99);
    newObject.setCharField('a');
    newObject.setDoubleField(50000000d);
    newObject.setFloatField(40000000f);
    newObject.setIntField(2);
    newObject.setLongField(30000L);
    newObject.setShortField((short) 1);
    return newObject;
}
Also used : BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass)

Example 17 with BaseFlatPrimitiveClass

use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.

the class JavaJavaFlatMappingTest method testProcessJavaJavaFlatFieldMapping.

@Test
public void testProcessJavaJavaFlatFieldMapping() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-flatprimitive.xml").toURI());
    AtlasSession session = context.createSession();
    BaseFlatPrimitiveClass sourceClass = generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class);
    session.setDefaultSourceDocument(sourceClass);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetFlatPrimitiveClass);
    validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
}
Also used : 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 18 with BaseFlatPrimitiveClass

use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.

the class JavaJavaFlatMappingTest method testProcessJavaJavaFlatFieldMappingBoxedPrimitives.

@Test
public void testProcessJavaJavaFlatFieldMappingBoxedPrimitives() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-flatprimitive-boxed.xml").toURI());
    AtlasSession session = context.createSession();
    BaseFlatPrimitiveClass sourceClass = generateFlatPrimitiveClassBoxedPrimitiveFieldsBoxedValues(SourceFlatPrimitiveClass.class);
    session.setDefaultSourceDocument(sourceClass);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetFlatPrimitiveClass);
    validateFlatPrimitiveClassBoxedPrimitiveFields((TargetFlatPrimitiveClass) object);
}
Also used : 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 19 with BaseFlatPrimitiveClass

use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.

the class JavaJavaFlatMappingTest method generateFlatPrimitiveClass.

protected BaseFlatPrimitiveClass generateFlatPrimitiveClass(Class<? extends BaseFlatPrimitiveClass> clazz) throws Exception {
    Class<?> targetClazz = this.getClass().getClassLoader().loadClass(clazz.getName());
    BaseFlatPrimitiveClass newObject = (BaseFlatPrimitiveClass) targetClazz.newInstance();
    newObject.setBooleanField(false);
    newObject.setByteField((byte) 99);
    newObject.setCharField('a');
    newObject.setDoubleField(50000000d);
    newObject.setFloatField(40000000f);
    newObject.setIntField(2);
    newObject.setLongField(30000L);
    newObject.setShortField((short) 1);
    return newObject;
}
Also used : BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass)

Example 20 with BaseFlatPrimitiveClass

use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.

the class JsonJavaFlatMappingTest method generateFlatPrimitiveClassBoxedPrimitiveFieldsBoxedValues.

protected BaseFlatPrimitiveClass generateFlatPrimitiveClassBoxedPrimitiveFieldsBoxedValues(Class<? extends BaseFlatPrimitiveClass> clazz) throws Exception {
    Class<?> targetClazz = this.getClass().getClassLoader().loadClass(clazz.getName());
    BaseFlatPrimitiveClass newObject = (BaseFlatPrimitiveClass) targetClazz.newInstance();
    newObject.setBoxedBooleanField(Boolean.valueOf(Boolean.TRUE));
    newObject.setBoxedByteField(new Byte((byte) 87));
    newObject.setBoxedCharField(new Character('z'));
    newObject.setBoxedDoubleField(new Double(90000000d));
    newObject.setBoxedFloatField(new Float(70000000f));
    newObject.setBoxedIntField(new Integer(5));
    newObject.setBoxedLongField(new Long(20000L));
    newObject.setBoxedShortField(new Short((short) 5));
    return newObject;
}
Also used : BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass)

Aggregations

BaseFlatPrimitiveClass (io.atlasmap.java.test.BaseFlatPrimitiveClass)22 AtlasContext (io.atlasmap.api.AtlasContext)7 AtlasSession (io.atlasmap.api.AtlasSession)7 File (java.io.File)7 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)6 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)4 Test (org.junit.Test)4 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)2 TargetFlatPrimitive (io.atlasmap.json.test.TargetFlatPrimitive)2 Validation (io.atlasmap.v2.Validation)1 Validations (io.atlasmap.v2.Validations)1