Search in sources :

Example 11 with LookupTable

use of eu.esdihumboldt.hale.common.lookup.LookupTable in project hale by halestudio.

the class LookupTableTypeTest method testStringLookup.

/**
 * Test if a simple lookup table containing only string values is the same
 * when converted to DOM and back again.
 */
@Test
public void testStringLookup() {
    Map<Value, Value> values = createStringLookup();
    LookupTable org = new LookupTableImpl(values);
    // convert to DOM
    Element fragment = HaleIO.getComplexElement(org);
    // convert back
    LookupTable conv = HaleIO.getComplexValue(fragment, LookupTable.class, null);
    checkTable(conv, values);
}
Also used : Element(org.w3c.dom.Element) Value(eu.esdihumboldt.hale.common.core.io.Value) LookupTable(eu.esdihumboldt.hale.common.lookup.LookupTable) LookupTableImpl(eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl) Test(org.junit.Test)

Example 12 with LookupTable

use of eu.esdihumboldt.hale.common.lookup.LookupTable in project hale by halestudio.

the class LookupTableTypeTest method testStringLookupJson.

/**
 * Test if a simple lookup table containing only string values is the same
 * when converted to JSON and back again.
 */
@Test
public void testStringLookupJson() {
    Map<Value, Value> values = createStringLookup();
    LookupTable org = new LookupTableImpl(values);
    // converter
    LookupTableType ltt = new LookupTableType();
    // convert to Json
    StringWriter writer = new StringWriter();
    ltt.toJson(org, writer);
    System.out.println(writer.toString());
    // convert back
    LookupTable conv = ltt.fromJson(new StringReader(writer.toString()), null);
    checkTable(conv, values);
}
Also used : StringWriter(java.io.StringWriter) Value(eu.esdihumboldt.hale.common.core.io.Value) LookupTable(eu.esdihumboldt.hale.common.lookup.LookupTable) StringReader(java.io.StringReader) LookupTableImpl(eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl) Test(org.junit.Test)

Example 13 with LookupTable

use of eu.esdihumboldt.hale.common.lookup.LookupTable in project hale by halestudio.

the class LookupTableTypeTest method testComplexLookupJson.

/**
 * Test if a lookup table containing only complex values is the same when
 * converted to JSON and back again.
 */
@Test
public void testComplexLookupJson() {
    Map<Value, Value> values2 = createComplexLookup();
    LookupTable org2 = new LookupTableImpl(values2);
    // converter
    LookupTableType ltt = new LookupTableType();
    // convert to Json
    StringWriter writer = new StringWriter();
    ltt.toJson(org2, writer);
    System.out.println(writer.toString());
    // convert back
    LookupTable conv = ltt.fromJson(new StringReader(writer.toString()), null);
    checkTable(conv, values2);
}
Also used : StringWriter(java.io.StringWriter) Value(eu.esdihumboldt.hale.common.core.io.Value) LookupTable(eu.esdihumboldt.hale.common.lookup.LookupTable) StringReader(java.io.StringReader) LookupTableImpl(eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl) Test(org.junit.Test)

Aggregations

LookupTable (eu.esdihumboldt.hale.common.lookup.LookupTable)13 Value (eu.esdihumboldt.hale.common.core.io.Value)12 LookupTableImpl (eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl)8 Test (org.junit.Test)6 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)4 Entity (eu.esdihumboldt.hale.common.align.model.Entity)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 StyledString (org.eclipse.jface.viewers.StyledString)2 Element (org.w3c.dom.Element)2 Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 Property (eu.esdihumboldt.hale.common.align.model.Property)1 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)1 PropertyValue (eu.esdihumboldt.hale.common.align.transformation.function.PropertyValue)1 NoResultException (eu.esdihumboldt.hale.common.align.transformation.function.impl.NoResultException)1 ComplexValue (eu.esdihumboldt.hale.common.core.io.impl.ComplexValue)1 StringValue (eu.esdihumboldt.hale.common.core.io.impl.StringValue)1 ServiceManager (eu.esdihumboldt.hale.common.core.service.ServiceManager)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1