Search in sources :

Example 31 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class MergeRowsMetaCheckTest method testCheckInputRowsDifferentRowMetaTypes.

@Test
public void testCheckInputRowsDifferentRowMetaTypes() throws KettleStepException {
    when(transMeta.getPrevStepFields(REFERENCE_STEP_NAME)).thenReturn(generateRowMeta10MixedTypes());
    when(transMeta.getPrevStepFields(COMPARISON_STEP_NAME)).thenReturn(generateRowMeta10Strings());
    meta.check(remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0], (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null);
    assertNotNull(remarks);
    assertTrue(remarks.size() >= 2);
    assertEquals(remarks.get(1).getType(), CheckResultInterface.TYPE_RESULT_ERROR);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Test(org.junit.Test)

Example 32 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class NamedClusterEmbedManagerTest method testPassEmbeddedMetastoreKey.

@Test
public void testPassEmbeddedMetastoreKey() {
    Variables mockVariables = mock(Variables.class);
    namedClusterEmbedManager.passEmbeddedMetastoreKey(mockVariables, "key");
    verify(mockVariables).setVariable(anyString(), anyString());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Test(org.junit.Test)

Example 33 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class BasePropertyParsingTest method setFields.

/**
 * Declare fields for test.
 */
protected void setFields(PropertyInputField... fields) throws Exception {
    meta.setInputFields(fields);
    meta.getFields(data.outputRowMeta, meta.getName(), null, null, new Variables(), null, null);
    data.convertRowMeta = data.outputRowMeta.cloneToType(ValueMetaInterface.TYPE_STRING);
}
Also used : Variables(org.pentaho.di.core.variables.Variables)

Example 34 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class RestMetaTest method testStepChecks.

@Test
public void testStepChecks() {
    RestMeta meta = new RestMeta();
    List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
    TransMeta transMeta = new TransMeta();
    StepMeta step = new StepMeta();
    RowMetaInterface prev = new RowMeta();
    RowMetaInterface info = new RowMeta();
    String[] input = new String[0];
    String[] output = new String[0];
    VariableSpace variables = new Variables();
    Repository repo = null;
    IMetaStore metaStore = null;
    // In a default configuration, it's expected that some errors will occur.
    // For this, we'll grab a baseline count of the number of errors
    // as the error count should decrease as we change configuration settings to proper values.
    remarks.clear();
    meta.check(remarks, transMeta, step, prev, input, output, info, variables, repo, metaStore);
    final int errorsDefault = getCheckResultErrorCount(remarks);
    assertTrue(errorsDefault > 0);
    // Setting the step to read the URL from a field should fix one of the check() errors
    meta.setUrlInField(true);
    meta.setUrlField("urlField");
    prev.addValueMeta(new ValueMetaString("urlField"));
    remarks.clear();
    meta.check(remarks, transMeta, step, prev, input, output, info, variables, repo, metaStore);
    int errorsCurrent = getCheckResultErrorCount(remarks);
    assertTrue(errorsDefault > errorsCurrent);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) VariableSpace(org.pentaho.di.core.variables.VariableSpace) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) Test(org.junit.Test)

Example 35 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class GetSubFoldersMetaTest method getFieldsTest.

@Test
public void getFieldsTest() throws KettleStepException {
    GetSubFoldersMeta stepMeta = new GetSubFoldersMeta();
    String stepName = UUID.randomUUID().toString();
    RowMeta rowMeta = new RowMeta();
    stepMeta.getFields(rowMeta, stepName, null, null, new Variables(), null, null);
    assertFalse(stepMeta.includeRowNumber());
    assertEquals(10, rowMeta.size());
    assertEquals("folderName", rowMeta.getValueMeta(0).getName());
    assertEquals("short_folderName", rowMeta.getValueMeta(1).getName());
    assertEquals("path", rowMeta.getValueMeta(2).getName());
    assertEquals("ishidden", rowMeta.getValueMeta(3).getName());
    assertEquals("isreadable", rowMeta.getValueMeta(4).getName());
    assertEquals("iswriteable", rowMeta.getValueMeta(5).getName());
    assertEquals("lastmodifiedtime", rowMeta.getValueMeta(6).getName());
    assertEquals("uri", rowMeta.getValueMeta(7).getName());
    assertEquals("rooturi", rowMeta.getValueMeta(8).getName());
    assertEquals("childrens", rowMeta.getValueMeta(9).getName());
    stepMeta.setIncludeRowNumber(true);
    rowMeta = new RowMeta();
    stepMeta.getFields(rowMeta, stepName, null, null, new Variables(), null, null);
    assertTrue(stepMeta.includeRowNumber());
    assertEquals(11, rowMeta.size());
    assertEquals("folderName", rowMeta.getValueMeta(0).getName());
    assertEquals("short_folderName", rowMeta.getValueMeta(1).getName());
    assertEquals("path", rowMeta.getValueMeta(2).getName());
    assertEquals("ishidden", rowMeta.getValueMeta(3).getName());
    assertEquals("isreadable", rowMeta.getValueMeta(4).getName());
    assertEquals("iswriteable", rowMeta.getValueMeta(5).getName());
    assertEquals("lastmodifiedtime", rowMeta.getValueMeta(6).getName());
    assertEquals("uri", rowMeta.getValueMeta(7).getName());
    assertEquals("rooturi", rowMeta.getValueMeta(8).getName());
    assertEquals("childrens", rowMeta.getValueMeta(9).getName());
    assertEquals(null, rowMeta.getValueMeta(10).getName());
    stepMeta.setRowNumberField("MyRowNumber");
    rowMeta = new RowMeta();
    stepMeta.getFields(rowMeta, stepName, null, null, new Variables(), null, null);
    assertEquals("MyRowNumber", stepMeta.getRowNumberField());
    assertEquals(11, rowMeta.size());
    assertEquals("MyRowNumber", rowMeta.getValueMeta(10).getName());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) RowMeta(org.pentaho.di.core.row.RowMeta) Test(org.junit.Test)

Aggregations

Variables (org.pentaho.di.core.variables.Variables)119 Test (org.junit.Test)67 TransMeta (org.pentaho.di.trans.TransMeta)31 ArrayList (java.util.ArrayList)25 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)20 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)20 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)20 StepMeta (org.pentaho.di.trans.step.StepMeta)18 RowMeta (org.pentaho.di.core.row.RowMeta)17 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)16 VariableSpace (org.pentaho.di.core.variables.VariableSpace)14 Repository (org.pentaho.di.repository.Repository)12 TableView (org.pentaho.di.ui.core.widget.TableView)10 FormAttachment (org.eclipse.swt.layout.FormAttachment)9 FormData (org.eclipse.swt.layout.FormData)9 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)9 Label (org.eclipse.swt.widgets.Label)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)7