Search in sources :

Example 36 with JavaClass

use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.

the class JavaConstructServiceComplexTest method testConstructTargetOrderFiltered.

@Test
public void testConstructTargetOrderFiltered() throws Exception {
    JavaClass javaClass = generateOrder("Target");
    Object targetObject = constructService.constructClass(javaClass, Arrays.asList("address"));
    assertNotNull(targetObject);
    assertTrue(targetObject instanceof TargetOrder);
    TargetOrder order = (TargetOrder) targetObject;
    assertNotNull(order.getAddress());
    assertTrue(order.getAddress() instanceof TargetAddress);
    TargetAddress address = (TargetAddress) order.getAddress();
    assertNull(address.getAddressLine1());
    assertNull(address.getAddressLine2());
    assertNull(address.getCity());
    assertNull(address.getState());
    assertNull(address.getZipCode());
    assertNull(order.getContact());
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass) TargetAddress(io.atlasmap.java.test.TargetAddress) TargetOrder(io.atlasmap.java.test.TargetOrder) Test(org.junit.Test)

Example 37 with JavaClass

use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.

the class JavaConstructServiceSimpleTest method generateJavaClass.

protected JavaClass generateJavaClass(String className) {
    JavaClass j = new JavaClass();
    j.setClassName(className);
    return j;
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass)

Example 38 with JavaClass

use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.

the class JavaConstructServiceTest method generateJavaClassInvalidEmptyClassName.

protected JavaClass generateJavaClassInvalidEmptyClassName() {
    JavaClass j = new JavaClass();
    j.setClassName("");
    return j;
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass)

Example 39 with JavaClass

use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.

the class JavaConstructServiceTest method testConstructClassCollectionList.

@Test
public void testConstructClassCollectionList() throws Exception {
    JavaClass javaClass = generateJavaClassCollection("java.lang.String", CollectionType.LIST, null, null);
    javaClass.setCollectionClassName("java.util.ArrayList");
    Object stringList = constructService.constructClass(javaClass, null);
    assertNotNull(stringList);
    assertTrue(stringList instanceof ArrayList<?>);
    assertTrue(((List<?>) stringList).isEmpty());
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass) Test(org.junit.Test)

Example 40 with JavaClass

use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.

the class ClassInspectionService method inspectClass.

public JavaClass inspectClass(String className, String classpath) throws InspectionException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Inspecting class: " + className + ", classPath: " + classpath);
    }
    if (className == null || classpath == null) {
        throw new InspectionException("ClassName and Classpath must be specified");
    }
    JavaClass d = null;
    try {
        JarClassLoader jcl = new JarClassLoader(new String[] { "target/reference-jars" });
        Class<?> clazz = jcl.loadClass(className);
        d = inspectClass(jcl, clazz);
    } catch (ClassNotFoundException cnfe) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Class was not found: " + className);
        }
        d = AtlasJavaModelFactory.createJavaClass();
        d.setClassName(className);
        d.setStatus(FieldStatus.NOT_FOUND);
    }
    return d;
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass)

Aggregations

JavaClass (io.atlasmap.java.v2.JavaClass)47 JavaField (io.atlasmap.java.v2.JavaField)21 Test (org.junit.Test)18 ClassInspectionService (io.atlasmap.java.inspect.ClassInspectionService)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 IOException (java.io.IOException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 TargetAddress (io.atlasmap.java.test.TargetAddress)2 TargetOrder (io.atlasmap.java.test.TargetOrder)2 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)2 ModifierList (io.atlasmap.java.v2.ModifierList)2 BaseMapping (io.atlasmap.v2.BaseMapping)2 Field (io.atlasmap.v2.Field)2 Method (java.lang.reflect.Method)2 ApplicationPath (javax.ws.rs.ApplicationPath)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 AtlasException (io.atlasmap.api.AtlasException)1 AtlasValidationException (io.atlasmap.api.AtlasValidationException)1 DocumentJavaFieldWriter (io.atlasmap.java.core.DocumentJavaFieldWriter)1