Search in sources :

Example 1 with DateExtractionHandler

use of eu.esdihumboldt.hale.io.appschema.writer.internal.DateExtractionHandler in project hale by halestudio.

the class AppSchemaMappingTest method testDateExtractionHandler.

@Test
public void testDateExtractionHandler() {
    final String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
    final String OCQL = "dateParse(" + SOURCE_UUID_V1 + ", '" + DATE_FORMAT + "')";
    DefaultCell cell = new DefaultCell();
    cell.setTransformationIdentifier(DateExtractionFunction.ID);
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    parameters.put(DateExtractionFunction.PARAMETER_DATE_FORMAT, new ParameterValue(DATE_FORMAT));
    cell.setSource(getUuidSourceProperty(unitDenormType));
    cell.setTarget(getFirstObservationDateTargetProperty());
    cell.setTransformationParameters(parameters);
    DateExtractionHandler handler = new DateExtractionHandler();
    AttributeMappingType attrMapping = handler.handlePropertyTransformation(getDefaultTypeCell(unitDenormType, landCoverUnitType), cell, new AppSchemaMappingContext(mappingWrapper));
    assertEquals(OCQL, attrMapping.getSourceExpression().getOCQL());
    assertEquals(TARGET_FIRST_OBSERVATION_DATE, attrMapping.getTargetAttribute());
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) AttributeMappingType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType) DefaultCell(eu.esdihumboldt.hale.common.align.model.impl.DefaultCell) AppSchemaMappingContext(eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext) DateExtractionHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.DateExtractionHandler) Test(org.junit.Test)

Aggregations

ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)1 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)1 AttributeMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType)1 DateExtractionHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.DateExtractionHandler)1 AppSchemaMappingContext (eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext)1 Test (org.junit.Test)1