Search in sources :

Example 6 with AssignHandler

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

the class AppSchemaMappingTest method testEncodeIfEmptyTrue.

@Test
public void testEncodeIfEmptyTrue() {
    final String XLINK_HREF_CONSTANT = "#lcu.123";
    final String OCQL_LITERAL = "'" + XLINK_HREF_CONSTANT + "'";
    DefaultCell assign = new DefaultCell();
    assign.setTransformationIdentifier(AssignFunction.ID);
    ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
    parameters.put(AssignFunction.PARAMETER_VALUE, new ParameterValue(XLINK_HREF_CONSTANT));
    assign.setTransformationParameters(parameters);
    assign.setTarget(getNestedUnitHrefTargetProperty());
    AssignHandler assignHandler = new AssignHandler();
    AttributeMappingType attrMapping = assignHandler.handlePropertyTransformation(getDefaultTypeCell(datasetType, landCoverDatasetType), assign, new AppSchemaMappingContext(mappingWrapper));
    assertNull(attrMapping.getSourceExpression());
    assertEquals("lcv:member", attrMapping.getTargetAttribute());
    assertNotNull(attrMapping.getClientProperty());
    assertEquals(1, attrMapping.getClientProperty().size());
    assertEquals("xlink:href", attrMapping.getClientProperty().get(0).getName());
    assertEquals(OCQL_LITERAL, attrMapping.getClientProperty().get(0).getValue());
    // expression is constant, so encodeIfEmpty=true
    assertNotNull(attrMapping.isEncodeIfEmpty());
    assertTrue(attrMapping.isEncodeIfEmpty());
}
Also used : AssignHandler(eu.esdihumboldt.hale.io.appschema.writer.internal.AssignHandler) 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) Test(org.junit.Test)

Aggregations

ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)6 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)6 AttributeMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType)6 AssignHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.AssignHandler)6 AppSchemaMappingContext (eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext)6 Test (org.junit.Test)6 ClientProperty (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType.ClientProperty)4 Cell (eu.esdihumboldt.hale.common.align.model.Cell)3 RenameHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.RenameHandler)2 Property (eu.esdihumboldt.hale.common.align.model.Property)1 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)1