Search in sources :

Example 26 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.

the class MongodbPredicateTest method setup.

@Before
public void setup() {
    for (int i = 0; i < 10; i++) {
        rowMeta.addValueMeta(new ValueMeta("sField" + i, ValueMetaInterface.TYPE_STRING, 50));
        rowMeta.addValueMeta(new ValueMeta("iField" + i, ValueMetaInterface.TYPE_INTEGER, 7));
    }
    resolver = new ValueMetaResolver(rowMeta);
    fieldMappings = new HashMap<String, String>();
}
Also used : ValueMetaResolver(org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver) ValueMeta(org.pentaho.di.core.row.ValueMeta) Before(org.junit.Before)

Example 27 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.

the class MongoDbInputStepAnalyzerTest method testCreateOutputFieldNode_noFields.

@Test
public void testCreateOutputFieldNode_noFields() throws Exception {
    ValueMetaInterface vmi = new ValueMeta("field1");
    IAnalysisContext context = mock(IAnalysisContext.class);
    when(meta.getMongoFields()).thenReturn(null);
    doReturn("thisStepName").when(analyzer).getStepName();
    when(node.getLogicalId()).thenReturn("logical id");
    IMetaverseNode node = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
    assertEquals("field1", node.getName());
    assertNull(node.getProperty(MongoDbInputStepAnalyzer.JSON_PATH));
    assertNull(node.getProperty(MongoDbInputStepAnalyzer.MINMAX_RANGE));
    assertNull(node.getProperty(MongoDbInputStepAnalyzer.OCCUR_RATIO));
    assertNull(node.getProperty(MongoDbInputStepAnalyzer.INDEXED_VALS));
    assertNull(node.getProperty(MongoDbInputStepAnalyzer.DISPARATE_TYPES));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IAnalysisContext(org.pentaho.metaverse.api.IAnalysisContext) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 28 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.

the class ExternalResourceStepAnalyzerTest method testCreateOutputFieldNode_resource.

@Test
public void testCreateOutputFieldNode_resource() throws Exception {
    IAnalysisContext context = mock(IAnalysisContext.class);
    doReturn("thisStepName").when(analyzer).getStepName();
    analyzer.rootNode = node;
    when(node.getLogicalId()).thenReturn("logical id");
    ValueMetaInterface vmi = new ValueMeta("name", 1);
    IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
    assertNotNull(outputFieldNode);
    assertNotNull(outputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
    assertEquals(ExternalResourceStepAnalyzer.RESOURCE, outputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
    assertEquals("OUTPUT_TYPE", outputFieldNode.getType());
    // the input node should be added by this step
    verify(builder).addNode(outputFieldNode);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IAnalysisContext(org.pentaho.metaverse.api.IAnalysisContext) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 29 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.

the class ExternalResourceStepAnalyzerTest method testGetOutputRowMetaInterfaces_isOutput.

@Test
public void testGetOutputRowMetaInterfaces_isOutput() throws Exception {
    String[] nextStepNames = new String[] { "nextStep1" };
    when(parentTransMeta.getNextStepNames(parentStepMeta)).thenReturn(nextStepNames);
    List<ValueMetaInterface> valueMetas = new ArrayList<>();
    valueMetas.add(new ValueMeta("field1"));
    valueMetas.add(new ValueMeta("field2"));
    RowMetaInterface rowMetaInterface = mock(RowMetaInterface.class);
    RowMetaInterface clone = mock(RowMetaInterface.class);
    when(rowMetaInterface.getValueMetaList()).thenReturn(valueMetas);
    when(rowMetaInterface.clone()).thenReturn(clone);
    doReturn(rowMetaInterface).when(analyzer).getOutputFields(meta);
    doReturn(true).when(analyzer).isOutput();
    Set<String> resourceFields = new HashSet<>();
    resourceFields.add("field1");
    doReturn(resourceFields).when(analyzer).getOutputResourceFields(meta);
    Map<String, RowMetaInterface> rowMetaInterfaces = analyzer.getOutputRowMetaInterfaces(meta);
    assertNotNull(rowMetaInterfaces);
    // should have the normal rmi as well as the resource ones
    assertEquals(nextStepNames.length * 2, rowMetaInterfaces.size());
    assertEquals(rowMetaInterface, rowMetaInterfaces.get(nextStepNames[0]));
    // field 2 isn't one of the fields written to the resource, it should be removed from the cloned RowMetaInterface
    verify(clone).removeValueMeta("field2");
    // field 1 is one of the fields written to the resource, it should not be removed from the cloned RowMetaInterface
    verify(clone, never()).removeValueMeta("field1");
}
Also used : ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 30 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.

the class ExternalResourceStepAnalyzerTest method testCreateOutputFieldNode.

@Test
public void testCreateOutputFieldNode() throws Exception {
    IAnalysisContext context = mock(IAnalysisContext.class);
    doReturn("thisStepName").when(analyzer).getStepName();
    analyzer.rootNode = node;
    when(node.getLogicalId()).thenReturn("logical id");
    ValueMetaInterface vmi = new ValueMeta("name", 1);
    IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode(context, vmi, "targetStep", DictionaryConst.NODE_TYPE_TRANS_FIELD);
    assertNotNull(outputFieldNode);
    assertNotNull(outputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
    assertEquals("targetStep", outputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
    assertEquals(DictionaryConst.NODE_TYPE_TRANS_FIELD, outputFieldNode.getType());
    // the input node should be added by this step
    verify(builder).addNode(outputFieldNode);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IAnalysisContext(org.pentaho.metaverse.api.IAnalysisContext) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Aggregations

ValueMeta (org.pentaho.di.core.row.ValueMeta)47 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)39 Test (org.junit.Test)18 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)14 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)13 RowMeta (org.pentaho.di.core.row.RowMeta)12 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 KettleValueException (org.pentaho.di.core.exception.KettleValueException)5 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)5 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)5 KettleException (org.pentaho.di.core.exception.KettleException)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)3 Matchers.anyString (org.mockito.Matchers.anyString)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 BatchUpdateException (java.sql.BatchUpdateException)1 Blob (java.sql.Blob)1 ResultSet (java.sql.ResultSet)1