Search in sources :

Example 41 with ParameterValue

use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.

the class OMLReaderTest method testClassificationMapping1.

/**
 * Test for classification mapping function in alignment2
 */
@Test
public void testClassificationMapping1() {
    Collection<? extends Cell> cells = alignment2.getCells();
    Iterator<? extends Cell> it = cells.iterator();
    Cell cell = null;
    while (it.hasNext()) {
        Cell temp = it.next();
        if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.hale.align.classification")) {
            cell = temp;
            break;
        }
    }
    ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
    List<ParameterValue> values = params.get("classificationMapping");
    for (int i = 0; i < values.size(); i++) {
        String temp = values.get(i).as(String.class);
        if (i == 0) {
            assertEquals("onGroundSurface 3", temp);
        }
        if (i == 1) {
            assertEquals("suspendedOrElevated 2", temp);
        }
        if (i == 2) {
            assertEquals("underground 1", temp);
        }
    }
    // check if all values were tested
    assertEquals(3, values.size());
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Test(org.junit.Test)

Example 42 with ParameterValue

use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.

the class OMLReaderTest method testIdentifier.

/**
 * test for the inspire identifier function in alignment5
 */
@Test
public void testIdentifier() {
    Collection<? extends Cell> cells = alignment5.getCells();
    Iterator<? extends Cell> it = cells.iterator();
    Cell cell = null;
    while (it.hasNext()) {
        Cell temp = it.next();
        if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.cst.functions.inspire.identifier")) {
            cell = temp;
            break;
        }
    }
    ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
    List<ParameterValue> country = params.get("countryName");
    List<ParameterValue> provider = params.get("providerName");
    List<ParameterValue> product = params.get("productName");
    List<ParameterValue> version = params.get("version");
    List<ParameterValue> versionNilReason = params.get("versionNilReason");
    // check if all parameters were set once
    assertEquals(1, country.size());
    assertEquals(1, provider.size());
    assertEquals(1, product.size());
    assertEquals(1, version.size());
    assertEquals(1, versionNilReason.size());
    // now test if they have correct values
    assertEquals("at", country.get(0).getValue());
    assertEquals("BEV", provider.get(0).getValue());
    assertEquals("humboldt-sample-transformed-data-CadastralParcels", product.get(0).getValue());
    assertEquals("", version.get(0).getValue());
    assertEquals("unknown", versionNilReason.get(0).getValue());
    // check if all parameters were tested
    assertEquals(5, params.size());
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Test(org.junit.Test)

Example 43 with ParameterValue

use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.

the class OMLReaderTest method testFormattedString2.

/**
 * Extended test for formatted string function in alignment3
 */
@Test
public void testFormattedString2() {
    Collection<? extends Cell> cells = alignment3.getCells();
    Iterator<? extends Cell> it = cells.iterator();
    Cell cell = null;
    while (it.hasNext()) {
        Cell temp = it.next();
        if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.hale.align.formattedstring")) {
            cell = temp;
            break;
        }
    }
    assertNotNull(cell);
    ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
    List<ParameterValue> values = params.get("pattern");
    assertEquals(1, values.size());
    // size is 1
    assertEquals("{flurstuecksnummer.AX_Flurstuecksnummer.zaehler}/{flurstuecksnummer.AX_Flurstuecksnummer.nenner}", values.get(0).getValue());
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Test(org.junit.Test)

Example 44 with ParameterValue

use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.

the class OMLReaderTest method testFormattedString1.

/**
 * Test for formatted string translation in aligment
 */
@Test
public void testFormattedString1() {
    Collection<? extends Cell> cells = alignment.getCells();
    Iterator<? extends Cell> it = cells.iterator();
    Cell cell = null;
    while (it.hasNext()) {
        Cell temp = it.next();
        if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.hale.align.formattedstring")) {
            cell = temp;
            break;
        }
    }
    ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
    List<ParameterValue> values = params.get("pattern");
    assertEquals(1, values.size());
    // size is 1, so "get(0)" works fine
    assertEquals("{id}-xxx-{details.address.street}", values.get(0).getValue());
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Test(org.junit.Test)

Example 45 with ParameterValue

use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.

the class OMLReaderTest method testNetworkExpansion2.

/**
 * Test for network expansion function in alignment5
 */
@Test
public void testNetworkExpansion2() {
    Collection<? extends Cell> cells = alignment5.getCells();
    Iterator<? extends Cell> it = cells.iterator();
    List<Cell> networkCells = new ArrayList<Cell>();
    while (it.hasNext()) {
        Cell temp = it.next();
        if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.cst.functions.geometric.networkexpansion")) {
            networkCells.add(temp);
        }
    }
    for (int i = 0; i < networkCells.size(); i++) {
        Cell cell = networkCells.get(i);
        ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
        List<ParameterValue> values = params.get("bufferWidth");
        String temp = values.get(0).as(String.class);
        if (i == 0) {
            assertEquals("50", temp);
        }
        if (i == 1) {
            assertEquals("5", temp);
        }
    }
    // check if all cells were tested
    assertEquals(2, networkCells.size());
}
Also used : ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) ArrayList(java.util.ArrayList) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Test(org.junit.Test)

Aggregations

ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)80 Test (org.junit.Test)29 Cell (eu.esdihumboldt.hale.common.align.model.Cell)28 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)21 AttributeMappingType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType)14 AppSchemaMappingContext (eu.esdihumboldt.hale.io.appschema.writer.internal.mapping.AppSchemaMappingContext)13 ArrayList (java.util.ArrayList)13 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)9 Property (eu.esdihumboldt.hale.common.align.model.Property)9 ClientProperty (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType.ClientProperty)9 Entity (eu.esdihumboldt.hale.common.align.model.Entity)8 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)8 Value (eu.esdihumboldt.hale.common.core.io.Value)8 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)8 TransformationException (eu.esdihumboldt.hale.common.align.transformation.function.TransformationException)7 Type (eu.esdihumboldt.hale.common.align.model.Type)6 AssignHandler (eu.esdihumboldt.hale.io.appschema.writer.internal.AssignHandler)6 JoinParameter (eu.esdihumboldt.hale.common.align.model.functions.join.JoinParameter)5 HashSet (java.util.HashSet)5 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)4