use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class OMLReaderTest method testFormattedString3.
/**
* Test for formatted string function in alignment5
*/
@Test
public void testFormattedString3() {
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.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("{Grundbuch}:{Nummer}:{Einlage}", values.get(0).getValue());
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue in project hale by halestudio.
the class OMLReaderTest method testClassificationMapping2.
/**
* Test for classification mapping function in alignment4
*/
@Test
public void testClassificationMapping2() {
Collection<? extends Cell> cells = alignment4.getCells();
Iterator<? extends Cell> it = cells.iterator();
List<Cell> classMapCells = new ArrayList<Cell>();
while (it.hasNext()) {
Cell temp = it.next();
if (temp.getTransformationIdentifier().equals("eu.esdihumboldt.hale.align.classification")) {
classMapCells.add(temp);
}
}
// test all cells that have a classification mapping function
for (int i = 0; i < classMapCells.size(); i++) {
Cell cell = classMapCells.get(i);
ListMultimap<String, ParameterValue> params = cell.getTransformationParameters();
List<ParameterValue> values = params.get("classificationMapping");
// for each cell too
for (int j = 0; j < values.size(); j++) {
String temp = values.get(j).as(String.class);
// test cell #1
if (i == 0 && j == 0) {
assertEquals("underConstruction 5", temp);
}
// test cell #2
if (i == 1 && j == 0) {
assertEquals("manMade 4", temp);
}
if (i == 1 && j == 1) {
assertEquals("natural 5", temp);
}
// test cell #3
if (i == 2 && j == 0) {
assertEquals("intermittent 6", temp);
}
if (i == 2 && j == 1) {
assertEquals("perennial 8", temp);
}
// test cell #4
if (i == 3 && j == 0) {
assertEquals("false 1", temp);
}
if (i == 3 && j == 1) {
assertEquals("true 2", temp);
}
}
}
// check if all cells with a classification mapping function were tested
assertEquals(4, classMapCells.size());
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue 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);
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue 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());
}
use of eu.esdihumboldt.hale.common.align.model.ParameterValue 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());
}
Aggregations