Search in sources :

Example 1 with FuzzyNumberCell

use of org.knime.core.data.def.FuzzyNumberCell in project knime-core by knime.

the class NodeSettingsTest method testStringDataCell.

/**
 * Test write/read of StringCells.
 *
 * @throws Exception Should not happen.
 */
@Test
public void testStringDataCell() throws Exception {
    try {
        m_settings.addDataCell(null, new StringCell("null"));
        fail();
    } catch (IllegalArgumentException iae) {
        assertTrue(true);
    }
    String key = "nullDataCell";
    m_settings.addDataCell(key, null);
    assertTrue(m_settings.containsKey(key));
    assertTrue(m_settings.getDataCell(key) == null);
    DataCell nullCell = new StringCell("null");
    assertTrue(m_settings.getDataCell(key, nullCell) == null);
    key = "kDataCell";
    m_settings.addDataCell(key, new StringCell("B"));
    assertTrue(m_settings.containsKey(key));
    assertTrue(m_settings.getDataCell(key).equals(new StringCell("B")));
    assertTrue(m_settings.getDataCell(key, null).equals(new StringCell("B")));
    key += "array";
    m_settings.addDataCellArray(key, new DataCell[] { new StringCell("T"), new StringCell("P"), new StringCell("M") });
    assertTrue(m_settings.containsKey(key));
    DataCell[] a = m_settings.getDataCellArray(key);
    assertTrue(a[0].equals(new StringCell("T")));
    assertTrue(a[1].equals(new StringCell("P")));
    assertTrue(a[2].equals(new StringCell("M")));
    a = m_settings.getDataCellArray(key, new DataCell[0]);
    assertTrue(a[0].equals(new StringCell("T")));
    assertTrue(a[1].equals(new StringCell("P")));
    assertTrue(a[2].equals(new StringCell("M")));
    key = "kDataCell_array_0";
    m_settings.addDataCellArray(key, new DataCell[0]);
    assertTrue(m_settings.containsKey(key));
    assertTrue(m_settings.getDataCellArray(key).length == 0);
    assertTrue(m_settings.getDataCellArray(key, new DataCell[1]).length == 0);
    key = "kDataCell-";
    m_settings.addDataCellArray(key, (DataCell[]) null);
    assertTrue(m_settings.containsKey(key));
    assertTrue(m_settings.getDataCellArray(key) == null);
    key = "unknownDataCell";
    DataCell unknownCell = new FuzzyNumberCell(0.0, 1.0, 2.0);
    m_settings.addDataCell(key, unknownCell);
    assertTrue(m_settings.containsKey(key));
    assertTrue(unknownCell.equals(m_settings.getDataCell(key)));
}
Also used : StringCell(org.knime.core.data.def.StringCell) DataCell(org.knime.core.data.DataCell) FuzzyNumberCell(org.knime.core.data.def.FuzzyNumberCell) Test(org.junit.Test)

Example 2 with FuzzyNumberCell

use of org.knime.core.data.def.FuzzyNumberCell in project knime-core by knime.

the class NodeSettingsTest method testDataCell.

/**
 * Test write/read of DataCells.
 *
 * @throws Exception Should not happen.
 */
@Test
public void testDataCell() throws Exception {
    StringCell s = new StringCell("stringi");
    m_settings.addDataCell("string", s);
    assertTrue(m_settings.containsKey("string"));
    assertTrue(m_settings.getDataCell("string").equals(s));
    DoubleCell d = new DoubleCell(45.42);
    m_settings.addDataCell("double", d);
    assertTrue(m_settings.containsKey("double"));
    assertTrue(m_settings.getDataCell("double").equals(d));
    IntCell i = new IntCell(11);
    m_settings.addDataCell("int", i);
    assertTrue(m_settings.containsKey("int"));
    assertTrue(m_settings.getDataCell("int").equals(i));
    DataCell m = DataType.getMissingCell();
    m_settings.addDataCell("missing", m);
    assertTrue(m_settings.containsKey("missing"));
    assertTrue(m_settings.getDataCell("missing").equals(m));
    ComplexNumberCell c = new ComplexNumberCell(5.4, 4.5);
    m_settings.addDataCell("complex", c);
    assertTrue(m_settings.containsKey("complex"));
    assertTrue(m_settings.getDataCell("complex").equals(c));
    FuzzyNumberCell n = new FuzzyNumberCell(1, 2, 4);
    m_settings.addDataCell("fnumber", n);
    assertTrue(m_settings.containsKey("fnumber"));
    assertTrue(m_settings.getDataCell("fnumber").equals(n));
    FuzzyIntervalCell f = new FuzzyIntervalCell(1, 2, 3, 4);
    m_settings.addDataCell("finterval", f);
    assertTrue(m_settings.containsKey("finterval"));
    assertTrue(m_settings.getDataCell("finterval").equals(f));
    DataCell unknownCell = new UnknownCell();
    m_settings.addDataCell("unknownCell", unknownCell);
    assertTrue(m_settings.containsKey("unknownCell"));
    assertTrue(m_settings.getDataCell("unknownCell").equals(unknownCell));
}
Also used : StringCell(org.knime.core.data.def.StringCell) DoubleCell(org.knime.core.data.def.DoubleCell) ComplexNumberCell(org.knime.core.data.def.ComplexNumberCell) DataCell(org.knime.core.data.DataCell) FuzzyNumberCell(org.knime.core.data.def.FuzzyNumberCell) FuzzyIntervalCell(org.knime.core.data.def.FuzzyIntervalCell) IntCell(org.knime.core.data.def.IntCell) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DataCell (org.knime.core.data.DataCell)2 FuzzyNumberCell (org.knime.core.data.def.FuzzyNumberCell)2 StringCell (org.knime.core.data.def.StringCell)2 ComplexNumberCell (org.knime.core.data.def.ComplexNumberCell)1 DoubleCell (org.knime.core.data.def.DoubleCell)1 FuzzyIntervalCell (org.knime.core.data.def.FuzzyIntervalCell)1 IntCell (org.knime.core.data.def.IntCell)1