Search in sources :

Example 66 with Cell

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

the class OMLReaderTest method testMathematicalExpression.

/**
 * Test for mathematical expression in alignment
 */
@Test
public void testMathematicalExpression() {
    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.cst.functions.numeric.mathexpression")) {
            cell = temp;
            break;
        }
    }
    ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
    List<ParameterValue> values = params.get("expression");
    // test the amount and the correctness of the parameter
    assertEquals(1, values.size());
    String date = values.get(0).as(String.class);
    assertEquals("income * age/10", date);
    // test the amount and the correctness of source properties
    ListMultimap<String, ? extends Entity> src = cell.getSource();
    // all source properties should be named "var" so we test if both lists
    // have the same size
    List<? extends Entity> srcCells = src.get("var");
    assertEquals(2, src.size());
    assertEquals(2, srcCells.size());
    // since we have now the right amount of source properties we can now
    // test the correctness of their names
    Entity srcCell1 = srcCells.get(0);
    Entity srcCell2 = srcCells.get(1);
    String name1 = srcCell1.getDefinition().getDefinition().getDisplayName();
    String name2 = srcCell2.getDefinition().getDefinition().getDisplayName();
    assertEquals("age", name1);
    assertEquals("income", name2);
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Test(org.junit.Test)

Example 67 with Cell

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

the class OMLReaderTest method testGeographicalName1.

/**
 * test for the inspire geographical name function in alignment6
 */
@Test
public void testGeographicalName1() {
    Collection<? extends Cell> cells = alignment6.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.geographicalname")) {
            cell = temp;
            break;
        }
    }
    ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
    List<ParameterValue> gender = params.get("grammaticalGender");
    List<ParameterValue> number = params.get("grammaticalNumber");
    List<ParameterValue> lang = params.get("language");
    List<ParameterValue> nameStatus = params.get("nameStatus");
    List<ParameterValue> nativeness = params.get("nativeness");
    List<ParameterValue> ipa = params.get("pronunciationIPA");
    List<ParameterValue> sound = params.get("pronunciationSoundLink");
    List<ParameterValue> source = params.get("sourceOfName");
    List<ParameterValue> script = params.get("script");
    List<ParameterValue> text = params.get("text");
    List<ParameterValue> trans = params.get("transliterationScheme");
    // test if all parameters were set only once
    assertEquals(1, gender.size());
    assertEquals(1, number.size());
    assertEquals(1, lang.size());
    assertEquals(1, nameStatus.size());
    assertEquals(1, nativeness.size());
    assertEquals(1, ipa.size());
    // sound shouldn't be available because in older version we couldn't
    // enter a value
    assertEquals(0, sound.size());
    assertEquals(1, source.size());
    assertEquals(1, script.size());
    assertEquals(1, text.size());
    assertEquals(1, trans.size());
    // now test if they have the correct values
    assertEquals("common", gender.get(0).getValue());
    assertEquals("dual", number.get(0).getValue());
    assertEquals("deu", lang.get(0).getValue());
    assertEquals("historical", nameStatus.get(0).getValue());
    assertEquals("exonym", nativeness.get(0).getValue());
    assertEquals("IDipa", ipa.get(0).getValue());
    assertEquals("source", source.get(0).getValue());
    assertEquals("IDscript", script.get(0).getValue());
    assertEquals("identifier", text.get(0).getValue());
    assertEquals("IDtrans", trans.get(0).getValue());
    // check if all parameters were tested (size is 10 because "sound" is
    // not defined in params)
    assertEquals(10, 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 68 with Cell

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

the class OMLReaderTest method testGeographicalName2.

/**
 * test for the inspire geographical name function in alignment7
 */
@Test
public void testGeographicalName2() {
    Collection<? extends Cell> cells = alignment7.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.geographicalname")) {
            cell = temp;
            break;
        }
    }
    ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
    List<ParameterValue> gender = params.get("grammaticalGender");
    List<ParameterValue> number = params.get("grammaticalNumber");
    List<ParameterValue> lang = params.get("language");
    List<ParameterValue> nameStatus = params.get("nameStatus");
    List<ParameterValue> nativeness = params.get("nativeness");
    List<ParameterValue> ipa = params.get("pronunciationIPA");
    List<ParameterValue> sound = params.get("pronunciationSoundLink");
    List<ParameterValue> source = params.get("sourceOfName");
    List<ParameterValue> script = params.get("script");
    List<ParameterValue> text = params.get("text");
    List<ParameterValue> trans = params.get("transliterationScheme");
    // test if all parameters (except the parameters for the spellings) were
    // set only once
    assertEquals(1, gender.size());
    assertEquals(1, number.size());
    assertEquals(1, lang.size());
    assertEquals(1, nameStatus.size());
    assertEquals(1, nativeness.size());
    assertEquals(1, ipa.size());
    // sound shouldn't be available because in older version we couldn't
    // enter a value
    assertEquals(0, sound.size());
    assertEquals(1, source.size());
    // spelling parameters
    assertEquals(2, script.size());
    assertEquals(2, text.size());
    assertEquals(2, trans.size());
    // now test if they have the correct values
    assertEquals("", gender.get(0).getValue());
    assertEquals("", number.get(0).getValue());
    assertEquals("esp", lang.get(0).getValue());
    assertEquals("official", nameStatus.get(0).getValue());
    assertEquals("endonym", nativeness.get(0).getValue());
    assertEquals("", ipa.get(0).getValue());
    assertEquals("unknown", source.get(0).getValue());
    for (int i = 0; i < text.size(); i++) {
        String spellText = text.get(i).as(String.class);
        String spellScript = script.get(i).as(String.class);
        String spellTrans = trans.get(i).as(String.class);
        if (i == 0) {
            assertEquals("identifier", spellText);
            assertEquals("idScript", spellScript);
            // no value set, initial value is "null"
            assertEquals(null, spellTrans);
        }
        if (i == 1) {
            assertEquals("name", spellText);
            // initial value is "eng", that was removed so we expect an
            // empty string
            assertEquals("", spellScript);
            assertEquals("nameTrans", spellTrans);
        }
    }
    // check if all parameters were tested (size is 13 because "sound" is
    // not defined in params and there are 2 spellings this time and 1
    // spelling has 3 parameters -> +3 parameters)
    assertEquals(13, 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 69 with Cell

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

the class OMLReaderTest method testCentroid1.

/**
 * Test for centroid function in alignment3
 */
@Test
public void testCentroid1() {
    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.geometric.centroid")) {
            cell = temp;
            break;
        }
    }
    // test if there is only one source and one target
    assertEquals(1, cell.getSource().size());
    assertEquals(1, cell.getTarget().size());
    List<? extends Entity> list = cell.getTarget().get(null);
    assertEquals(1, list.size());
    Entity ent = list.get(0);
    String name = ent.getDefinition().getDefinition().getDisplayName();
    assertEquals("referencePoint", name);
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) Cell(eu.esdihumboldt.hale.common.align.model.Cell) Test(org.junit.Test)

Example 70 with Cell

use of eu.esdihumboldt.hale.common.align.model.Cell 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)

Aggregations

Cell (eu.esdihumboldt.hale.common.align.model.Cell)123 ArrayList (java.util.ArrayList)33 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)28 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)28 Test (org.junit.Test)27 Entity (eu.esdihumboldt.hale.common.align.model.Entity)24 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)24 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)18 BaseAlignmentCell (eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell)16 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)16 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)16 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)15 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)13 HashSet (java.util.HashSet)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 Type (eu.esdihumboldt.hale.common.align.model.Type)11 List (java.util.List)11 ModifiableCell (eu.esdihumboldt.hale.common.align.model.ModifiableCell)9 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)9 Property (eu.esdihumboldt.hale.common.align.model.Property)8