use of io.atlasmap.java.test.DateTimeClass in project atlasmap by atlasmap.
the class JavaJavaDateTimeMappingTest method doTest.
private void doTest(int offset) throws Exception {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("JavaJavaDateTimeMapping");
addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.SOURCE);
addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.TARGET);
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
for (int i = 0; i < DATE_TIME_FIELDS.length; i++) {
int targetIndex = offset + i < DATE_TIME_FIELDS.length ? offset + i : offset + i - DATE_TIME_FIELDS.length;
JavaField sourceField = copyJavaField(DATE_TIME_FIELDS[i]);
JavaField targetField = copyJavaField(DATE_TIME_FIELDS[targetIndex]);
if (UNSUPPORTED.containsKey(sourceField.getFieldType()) && UNSUPPORTED.get(sourceField.getFieldType()).equals(targetField.getFieldType())) {
sourceField = copyJavaField(targetField);
}
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(sourceField);
mfm.getOutputField().add(targetField);
mappings.add(mfm);
}
AtlasContext context = ((DefaultAtlasContextFactory) atlasContextFactory).createContext(atlasMapping);
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(createSource());
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof DateTimeClass);
validateTarget((DateTimeClass) object);
}
use of io.atlasmap.java.test.DateTimeClass in project atlasmap by atlasmap.
the class JavaJavaDateTimeMappingTest method doTest.
private void doTest(int offset) throws Exception {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("JavaJavaDateTimeMapping");
addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.SOURCE);
addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.TARGET);
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
for (int i = 0; i < DATE_TIME_FIELDS.length; i++) {
int targetIndex = offset + i < DATE_TIME_FIELDS.length ? offset + i : offset + i - DATE_TIME_FIELDS.length;
JavaField sourceField = copyJavaField(DATE_TIME_FIELDS[i]);
JavaField targetField = copyJavaField(DATE_TIME_FIELDS[targetIndex]);
if (UNSUPPORTED.containsKey(sourceField.getFieldType()) && UNSUPPORTED.get(sourceField.getFieldType()).equals(targetField.getFieldType())) {
sourceField = copyJavaField(targetField);
}
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(sourceField);
mfm.getOutputField().add(targetField);
mappings.add(mfm);
}
AtlasContext context = ((DefaultAtlasContextFactory) atlasContextFactory).createContext(atlasMapping);
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(createSource());
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof DateTimeClass);
validateTarget((DateTimeClass) object);
}
use of io.atlasmap.java.test.DateTimeClass in project atlasmap by atlasmap.
the class JavaJavaDateTimeMappingTest method createSource.
private DateTimeClass createSource() {
DateTimeClass sourceClass = new DateTimeClass();
sourceClass.setCalendarField(Calendar.getInstance());
sourceClass.setDateField(Date.from(Instant.now()));
sourceClass.setGregorianCalendarField((GregorianCalendar) GregorianCalendar.getInstance());
sourceClass.setLocalDateField(LocalDate.now());
sourceClass.setLocalDateTimeField(LocalDateTime.now());
sourceClass.setLocalTimeField(LocalTime.now());
sourceClass.setMonthDayField(MonthDay.now());
sourceClass.setSqlDateField(new java.sql.Date(Instant.now().toEpochMilli()));
sourceClass.setSqlTimeField(new java.sql.Time(Instant.now().toEpochMilli()));
sourceClass.setSqlTimestampField(new java.sql.Timestamp(Instant.now().toEpochMilli()));
sourceClass.setYearField(Year.now());
sourceClass.setYearMonthField(YearMonth.now());
sourceClass.setZonedDateTimeField(ZonedDateTime.now());
return sourceClass;
}
use of io.atlasmap.java.test.DateTimeClass in project atlasmap by atlasmap.
the class JavaJavaDateTimeMappingTest method createSource.
private DateTimeClass createSource() {
DateTimeClass sourceClass = new DateTimeClass();
sourceClass.setCalendarField(Calendar.getInstance());
sourceClass.setDateField(Date.from(Instant.now()));
sourceClass.setGregorianCalendarField((GregorianCalendar) GregorianCalendar.getInstance());
sourceClass.setLocalDateField(LocalDate.now());
sourceClass.setLocalDateTimeField(LocalDateTime.now());
sourceClass.setLocalTimeField(LocalTime.now());
sourceClass.setMonthDayField(MonthDay.now());
sourceClass.setSqlDateField(new java.sql.Date(Instant.now().toEpochMilli()));
sourceClass.setSqlTimeField(new java.sql.Time(Instant.now().toEpochMilli()));
sourceClass.setSqlTimestampField(new java.sql.Timestamp(Instant.now().toEpochMilli()));
sourceClass.setYearField(Year.now());
sourceClass.setYearMonthField(YearMonth.now());
sourceClass.setZonedDateTimeField(ZonedDateTime.now());
return sourceClass;
}
Aggregations