Search in sources :

Example 21 with JavaClass

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

the class ClassValidationUtil method validateFlatPrimitiveClassTwoDimArray.

public static void validateFlatPrimitiveClassTwoDimArray(ClassInspectionService classInspectionService, Class<?> clazz, String className) {
    JavaClass flatClass = classInspectionService.inspectClass(clazz);
    validateFlatClass(flatClass);
    assertEquals(CollectionType.ARRAY, flatClass.getCollectionType());
    assertEquals(new Integer(2), flatClass.getArrayDimensions());
    assertEquals(null, flatClass.getArraySize());
    assertFalse(flatClass.isInterface());
    assertEquals(className, flatClass.getClassName());
    validateFlatPrimitiveFields(flatClass);
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass)

Example 22 with JavaClass

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

the class ClassValidationUtil method validateFlatPrimitiveClassThreeDimArray.

public static void validateFlatPrimitiveClassThreeDimArray(ClassInspectionService classInspectionService, Class<?> clazz, String className) {
    JavaClass flatClass = classInspectionService.inspectClass(clazz);
    validateFlatClass(flatClass);
    assertEquals(CollectionType.ARRAY, flatClass.getCollectionType());
    assertEquals(new Integer(3), flatClass.getArrayDimensions());
    assertFalse(flatClass.isInterface());
    assertEquals(className, flatClass.getClassName());
    validateFlatPrimitiveFields(flatClass);
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass)

Example 23 with JavaClass

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

the class ComplexClassInspectTest method testComplexClassSourceOrder.

@Test
public void testComplexClassSourceOrder() {
    JavaClass c = classInspectionService.inspectClass(SourceOrder.class);
    assertNotNull(c);
    assertEquals("io.atlasmap.java.test.SourceOrder", c.getClassName());
    assertEquals(String.format(AtlasJavaModelFactory.URI_FORMAT, "io.atlasmap.java.test.SourceOrder"), c.getUri());
    validateComplexClass(c);
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass) Test(org.junit.Test)

Example 24 with JavaClass

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

the class ComplexClassInspectTest method testComplexClassTargetOrder.

@Test
public void testComplexClassTargetOrder() {
    JavaClass c = classInspectionService.inspectClass(TargetOrder.class);
    assertNotNull(c);
    assertEquals("io.atlasmap.java.test.TargetOrder", c.getClassName());
    assertEquals(String.format(AtlasJavaModelFactory.URI_FORMAT, "io.atlasmap.java.test.TargetOrder"), c.getUri());
    validateComplexClass(c);
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass) Test(org.junit.Test)

Example 25 with JavaClass

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

the class ClassInspectionServiceTest method testDateTimeViaGetter.

@Test
public void testDateTimeViaGetter() {
    JavaClass javaClass = classInspectionService.inspectClass(DateTimeGetter.class);
    assertEquals(14, javaClass.getJavaFields().getJavaField().size());
    for (JavaField field : javaClass.getJavaFields().getJavaField()) {
        if ("year".equals(field.getName())) {
            assertEquals("java.time.Year", field.getClassName());
            assertEquals(FieldType.DATE, field.getFieldType());
            assertEquals("getYear", field.getGetMethod());
        } else if ("month".equals(field.getName())) {
            assertEquals("java.time.Month", field.getClassName());
            assertEquals(FieldType.DATE, field.getFieldType());
            assertEquals("getMonth", field.getGetMethod());
        } else if ("yearMonth".equals(field.getName())) {
            assertEquals("java.time.YearMonth", field.getClassName());
            assertEquals(FieldType.DATE, field.getFieldType());
            assertEquals("getYearMonth", field.getGetMethod());
        } else if ("monthDay".equals(field.getName())) {
            assertEquals("java.time.MonthDay", field.getClassName());
            assertEquals(FieldType.DATE, field.getFieldType());
            assertEquals("getMonthDay", field.getGetMethod());
        } else if ("localDate".equals(field.getName())) {
            assertEquals("java.time.LocalDate", field.getClassName());
            assertEquals(FieldType.DATE, field.getFieldType());
            assertEquals("getLocalDate", field.getGetMethod());
        } else if ("localTime".equals(field.getName())) {
            assertEquals("java.time.LocalTime", field.getClassName());
            assertEquals(FieldType.TIME, field.getFieldType());
            assertEquals("getLocalTime", field.getGetMethod());
        } else if ("localDateTime".equals(field.getName())) {
            assertEquals("java.time.LocalDateTime", field.getClassName());
            assertEquals(FieldType.DATE_TIME, field.getFieldType());
            assertEquals("getLocalDateTime", field.getGetMethod());
        } else if ("zonedDateTime".equals(field.getName())) {
            assertEquals("java.time.ZonedDateTime", field.getClassName());
            assertEquals(FieldType.DATE_TIME_TZ, field.getFieldType());
            assertEquals("getZonedDateTime", field.getGetMethod());
        } else if ("calendar".equals(field.getName())) {
            assertEquals("java.util.Calendar", field.getClassName());
            assertEquals(FieldType.DATE_TIME_TZ, field.getFieldType());
            assertEquals("getCalendar", field.getGetMethod());
        } else if ("date".equals(field.getName())) {
            assertEquals("java.util.Date", field.getClassName());
            assertEquals(FieldType.DATE_TIME, field.getFieldType());
            assertEquals("getDate", field.getGetMethod());
        } else if ("gregorianCalendar".equals(field.getName())) {
            assertEquals("java.util.GregorianCalendar", field.getClassName());
            assertEquals(FieldType.DATE_TIME_TZ, field.getFieldType());
            assertEquals("getGregorianCalendar", field.getGetMethod());
        } else if ("sqlDate".equals(field.getName())) {
            assertEquals("java.sql.Date", field.getClassName());
            assertEquals(FieldType.DATE, field.getFieldType());
            assertEquals("getSqlDate", field.getGetMethod());
        } else if ("sqlTime".equals(field.getName())) {
            assertEquals("java.sql.Time", field.getClassName());
            assertEquals(FieldType.TIME, field.getFieldType());
            assertEquals("getSqlTime", field.getGetMethod());
        } else if ("sqlTimestamp".equals(field.getName())) {
            assertEquals("java.sql.Timestamp", field.getClassName());
            assertEquals(FieldType.DATE_TIME, field.getFieldType());
            assertEquals("getSqlTimestamp", field.getGetMethod());
        } else {
            fail("Unsupported field was detected: " + field);
        }
    }
}
Also used : JavaField(io.atlasmap.java.v2.JavaField) JavaClass(io.atlasmap.java.v2.JavaClass) Test(org.junit.Test)

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