Search in sources :

Example 1 with ProducerRegistry

use of org.knime.core.data.convert.map.ProducerRegistry in project knime-core by knime.

the class MappingFrameworkTest method availableProductionPathsTest.

/**
 * Test getting all available production paths from {@link ProducerRegistry}
 */
@Test
public void availableProductionPathsTest() {
    final ProducerRegistry<String, H2OSource> reg = MappingFramework.forSourceType(H2OSource.class);
    final JavaToDataCellConverterRegistry convReg = JavaToDataCellConverterRegistry.getInstance();
    assertTrue("Expected to be empty but is: " + reg.getAvailableProductionPaths().stream().map(pp -> Objects.toString(pp, "<null>")).collect(Collectors.joining("\n", "\"", "\"")), reg.getAvailableProductionPaths().isEmpty());
    reg.register(intProducer);
    final List<ProductionPath> paths = reg.getAvailableProductionPaths();
    assertCollectionEquals(new Object[] { new ProductionPath(intProducer, convReg.getConverterFactories(Integer.class, IntCell.TYPE).stream().findFirst().get()), new ProductionPath(intProducer, convReg.getConverterFactories(Integer.class, LongCell.TYPE).stream().findFirst().get()), new ProductionPath(intProducer, convReg.getConverterFactories(Integer.class, DoubleCell.TYPE).stream().findFirst().get()) }, paths);
}
Also used : CellValueProducer(org.knime.core.data.convert.map.CellValueProducer) LongValue(org.knime.core.data.LongValue) Arrays(java.util.Arrays) RowKey(org.knime.core.data.RowKey) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ProducerRegistry(org.knime.core.data.convert.map.ProducerRegistry) MappingFramework(org.knime.core.data.convert.map.MappingFramework) ProductionPath(org.knime.core.data.convert.map.ProductionPath) NodeSettings(org.knime.core.node.NodeSettings) LongCell(org.knime.core.data.def.LongCell) ArrayList(java.util.ArrayList) JavaToDataCellConverterFactory(org.knime.core.data.convert.datacell.JavaToDataCellConverterFactory) DataCellToJavaConverterFactory(org.knime.core.data.convert.java.DataCellToJavaConverterFactory) SerializeUtil(org.knime.core.data.convert.util.SerializeUtil) SimpleCellValueProducerFactory(org.knime.core.data.convert.map.SimpleCellValueProducerFactory) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) Destination(org.knime.core.data.convert.map.Destination) Source(org.knime.core.data.convert.map.Source) StringValue(org.knime.core.data.StringValue) IntValue(org.knime.core.data.IntValue) CellValueConsumerFactory(org.knime.core.data.convert.map.CellValueConsumerFactory) DefaultRow(org.knime.core.data.def.DefaultRow) IntCell(org.knime.core.data.def.IntCell) DataValue(org.knime.core.data.DataValue) Collection(java.util.Collection) CellValueConsumer(org.knime.core.data.convert.map.CellValueConsumer) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) DoubleCell(org.knime.core.data.def.DoubleCell) Collectors(java.util.stream.Collectors) ConsumptionPath(org.knime.core.data.convert.map.ConsumptionPath) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) DataRow(org.knime.core.data.DataRow) Objects(java.util.Objects) DataCellToJavaConverterRegistry(org.knime.core.data.convert.java.DataCellToJavaConverterRegistry) List(java.util.List) Stream(java.util.stream.Stream) Assert.assertFalse(org.junit.Assert.assertFalse) MissingCell(org.knime.core.data.MissingCell) Optional(java.util.Optional) SimpleCellValueConsumerFactory(org.knime.core.data.convert.map.SimpleCellValueConsumerFactory) StringCell(org.knime.core.data.def.StringCell) Config(org.knime.core.node.config.Config) DataType(org.knime.core.data.DataType) JavaToDataCellConverterRegistry(org.knime.core.data.convert.datacell.JavaToDataCellConverterRegistry) CellValueProducerFactory(org.knime.core.data.convert.map.CellValueProducerFactory) Assert.assertEquals(org.junit.Assert.assertEquals) JavaToDataCellConverterRegistry(org.knime.core.data.convert.datacell.JavaToDataCellConverterRegistry) ProductionPath(org.knime.core.data.convert.map.ProductionPath) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Assert.assertArrayEquals (org.junit.Assert.assertArrayEquals)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotEquals (org.junit.Assert.assertNotEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1 DataRow (org.knime.core.data.DataRow)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 DataType (org.knime.core.data.DataType)1 DataValue (org.knime.core.data.DataValue)1 IntValue (org.knime.core.data.IntValue)1 LongValue (org.knime.core.data.LongValue)1