Search in sources :

Example 11 with LookupTableImpl

use of eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl 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 12 with LookupTableImpl

use of eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl 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

LookupTableImpl (eu.esdihumboldt.hale.common.lookup.impl.LookupTableImpl)12 Value (eu.esdihumboldt.hale.common.core.io.Value)11 LookupTable (eu.esdihumboldt.hale.common.lookup.LookupTable)8 Test (org.junit.Test)5 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)3 LookupTableInfoImpl (eu.esdihumboldt.hale.common.lookup.impl.LookupTableInfoImpl)3 HashMap (java.util.HashMap)3 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 StyledString (org.eclipse.jface.viewers.StyledString)2 Element (org.w3c.dom.Element)2 Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)1 ComplexValue (eu.esdihumboldt.hale.common.core.io.impl.ComplexValue)1 StringValue (eu.esdihumboldt.hale.common.core.io.impl.StringValue)1 LookupService (eu.esdihumboldt.hale.common.lookup.LookupService)1 LookupTableInfo (eu.esdihumboldt.hale.common.lookup.LookupTableInfo)1 LookupExportAdvisor (eu.esdihumboldt.hale.common.lookup.internal.LookupExportAdvisor)1 LookupLoadAdvisor (eu.esdihumboldt.hale.common.lookup.internal.LookupLoadAdvisor)1 Enumeration (eu.esdihumboldt.hale.common.schema.model.constraint.type.Enumeration)1