use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.
the class ClassInspectionServiceTest method testDateTimeViaSetter.
@Test
public void testDateTimeViaSetter() {
JavaClass javaClass = classInspectionService.inspectClass(DateTimeSetter.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("setYear", field.getSetMethod());
} else if ("month".equals(field.getName())) {
assertEquals("java.time.Month", field.getClassName());
assertEquals(FieldType.DATE, field.getFieldType());
assertEquals("setMonth", field.getSetMethod());
} else if ("yearMonth".equals(field.getName())) {
assertEquals("java.time.YearMonth", field.getClassName());
assertEquals(FieldType.DATE, field.getFieldType());
assertEquals("setYearMonth", field.getSetMethod());
} else if ("monthDay".equals(field.getName())) {
assertEquals("java.time.MonthDay", field.getClassName());
assertEquals(FieldType.DATE, field.getFieldType());
assertEquals("setMonthDay", field.getSetMethod());
} else if ("localDate".equals(field.getName())) {
assertEquals("java.time.LocalDate", field.getClassName());
assertEquals(FieldType.DATE, field.getFieldType());
assertEquals("setLocalDate", field.getSetMethod());
} else if ("localTime".equals(field.getName())) {
assertEquals("java.time.LocalTime", field.getClassName());
assertEquals(FieldType.TIME, field.getFieldType());
assertEquals("setLocalTime", field.getSetMethod());
} else if ("localDateTime".equals(field.getName())) {
assertEquals("java.time.LocalDateTime", field.getClassName());
assertEquals(FieldType.DATE_TIME, field.getFieldType());
assertEquals("setLocalDateTime", field.getSetMethod());
} else if ("zonedDateTime".equals(field.getName())) {
assertEquals("java.time.ZonedDateTime", field.getClassName());
assertEquals(FieldType.DATE_TIME_TZ, field.getFieldType());
assertEquals("setZonedDateTime", field.getSetMethod());
} else if ("calendar".equals(field.getName())) {
assertEquals("java.util.Calendar", field.getClassName());
assertEquals(FieldType.DATE_TIME_TZ, field.getFieldType());
assertEquals("setCalendar", field.getSetMethod());
} else if ("date".equals(field.getName())) {
assertEquals("java.util.Date", field.getClassName());
assertEquals(FieldType.DATE_TIME, field.getFieldType());
assertEquals("setDate", field.getSetMethod());
} else if ("gregorianCalendar".equals(field.getName())) {
assertEquals("java.util.GregorianCalendar", field.getClassName());
assertEquals(FieldType.DATE_TIME_TZ, field.getFieldType());
assertEquals("setGregorianCalendar", field.getSetMethod());
} else if ("sqlDate".equals(field.getName())) {
assertEquals("java.sql.Date", field.getClassName());
assertEquals(FieldType.DATE, field.getFieldType());
assertEquals("setSqlDate", field.getSetMethod());
} else if ("sqlTime".equals(field.getName())) {
assertEquals("java.sql.Time", field.getClassName());
assertEquals(FieldType.TIME, field.getFieldType());
assertEquals("setSqlTime", field.getSetMethod());
} else if ("sqlTimestamp".equals(field.getName())) {
assertEquals("java.sql.Timestamp", field.getClassName());
assertEquals(FieldType.DATE_TIME, field.getFieldType());
assertEquals("setSqlTimestamp", field.getSetMethod());
} else {
fail("Unsupported field was detected: " + field);
}
}
}
use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.
the class ClassValidationUtil method validateFlatPrimitiveFields.
public static void validateFlatPrimitiveFields(JavaClass flatClass) {
assertNotNull(flatClass.getPackageName());
assertEquals("io.atlasmap.java.test", flatClass.getPackageName());
assertNotNull(flatClass.getJavaFields());
assertNotNull(flatClass.getJavaFields().getJavaField());
assertFalse(flatClass.getJavaFields().getJavaField().isEmpty());
assertEquals(new Integer(34), new Integer(flatClass.getJavaFields().getJavaField().size()));
assertNotNull(flatClass.getJavaEnumFields());
assertNotNull(flatClass.getJavaEnumFields().getJavaEnumField());
assertTrue(flatClass.getJavaEnumFields().getJavaEnumField().isEmpty());
for (JavaField f : flatClass.getJavaFields().getJavaField()) {
assertNotNull(f);
JavaField j = f;
assertNotNull(j.getName());
switch(j.getFieldType()) {
case BOOLEAN:
if (CollectionType.ARRAY.equals(j.getCollectionType())) {
validatePrimitiveField("boolean", "Boolean", j, false);
} else {
validatePrimitiveField("boolean", "Boolean", j, true);
}
break;
case BYTE:
validatePrimitiveField("byte", "Byte", j);
break;
case CHAR:
validatePrimitiveField("char", "Char", j);
break;
case DOUBLE:
validatePrimitiveField("double", "Double", j);
break;
case FLOAT:
validatePrimitiveField("float", "Float", j);
break;
case INTEGER:
validatePrimitiveField("int", "Int", j);
break;
case LONG:
validatePrimitiveField("long", "Long", j);
break;
case SHORT:
validatePrimitiveField("short", "Short", j);
break;
case STRING:
validatePrimitiveField("string", "String", j);
break;
default:
fail("Extra field detected: " + j.getName());
}
}
}
use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.
the class JavaConstructServiceComplexListTest method generateOrderList.
protected JavaClass generateOrderList(String prefix) {
JavaClass j = classInspectionService.inspectClass("io.atlasmap.java.test." + prefix + "OrderList");
for (JavaField jf : j.getJavaFields().getJavaField()) {
if (jf.getPath().equals("orders")) {
jf.setClassName("io.atlasmap.java.test." + prefix + "Order");
jf.setCollectionClassName("java.util.ArrayList");
}
if (jf instanceof JavaClass) {
for (JavaField cjf : ((JavaClass) jf).getJavaFields().getJavaField()) {
if (cjf.getPath().equals("orders.contact")) {
cjf.setClassName("io.atlasmap.java.test." + prefix + "Contact");
}
if (cjf.getPath().equals("orders.address")) {
cjf.setClassName("io.atlasmap.java.test." + prefix + "Address");
}
}
}
}
return j;
}
use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.
the class ClassInspectionServiceITest method testInspectClassClassNameClassPath45.
@Test
public void testInspectClassClassNameClassPath45() throws InspectionException {
JavaClass javaClazz = classInspectionService.inspectClass("io.syndesis.connector.salesforce.Contact", "target/reference-jars/salesforce-upsert-contact-connector-0.4.5.jar:target/reference-jars/camel-salesforce-2.19.0.jar");
assertNotNull(javaClazz);
}
use of io.atlasmap.java.v2.JavaClass in project atlasmap by atlasmap.
the class ClassInspectionServiceITest method testInspectClassClassNameClassPath.
@Test
public void testInspectClassClassNameClassPath() throws InspectionException {
JavaClass javaClazz = classInspectionService.inspectClass("io.atlasmap.java.test.v2.FlatPrimitiveClass", "target/reference-jars/atlas-java-test-model-1.16.0-SNAPSHOT.jar");
assertNotNull(javaClazz);
}
Aggregations