Search in sources :

Example 41 with Variables

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

the class BaseTextParsingTest method setFields.

/**
 * Declare fields for test.
 *
 * TODO: move to BaseParsingTest after CSV moving to BaseFileInput
 */
protected void setFields(BaseFileField... fields) throws Exception {
    meta.inputFields = 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 42 with Variables

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

the class TextFileInputContentParsingTest method testFilterVariables.

@Test
public void testFilterVariables() throws Exception {
    initByFile("default.csv");
    Variables vars = new Variables();
    vars.setVariable("VAR_TEST", "second");
    data.filterProcessor = new TextFileFilterProcessor(new TextFileFilter[] { new TextFileFilter(0, "${VAR_TEST}", false, false) }, vars);
    setFields(new BaseFileField("f1", -1, -1), new BaseFileField("f2", -1, -1), new BaseFileField("f2", -1, -1));
    process();
    check(new Object[][] { { "first", "1", "1.1" }, { "third", "3", "3.3" } });
}
Also used : Variables(org.pentaho.di.core.variables.Variables) BaseFileField(org.pentaho.di.trans.steps.file.BaseFileField) Test(org.junit.Test)

Example 43 with Variables

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

the class GetRepositoryNamesTest method init.

private void init(Repository repository, String directoryName, boolean includeSubFolders, String nameMask, String exludeNameMask, ObjectTypeSelection typeSelection, int itemCount) throws KettleException {
    VariableSpace vars = new Variables();
    vars.setVariable("DirName", "/subdir1");
    vars.setVariable("IncludeMask", ".*");
    vars.setVariable("ExcludeMask", "");
    GetRepositoryNamesMeta meta = new GetRepositoryNamesMeta();
    meta.setDirectory(new String[] { directoryName });
    meta.setNameMask(new String[] { nameMask });
    meta.setExcludeNameMask(new String[] { exludeNameMask });
    meta.setIncludeSubFolders(new boolean[] { includeSubFolders });
    meta.setObjectTypeSelection(typeSelection);
    StepMeta stepMeta = new StepMeta("GetRepoNamesStep", meta);
    TransMeta transMeta = new TransMeta(vars);
    transMeta.setRepository(repository);
    transMeta.addStep(stepMeta);
    GetRepositoryNamesData data = (GetRepositoryNamesData) meta.getStepData();
    GetRepositoryNames step = new GetRepositoryNames(stepMeta, data, 0, transMeta, new Trans(transMeta));
    step.init(meta, data);
    assertNotNull(data.list);
    assertEquals(itemCount, data.list.size());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) VariableSpace(org.pentaho.di.core.variables.VariableSpace) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Trans(org.pentaho.di.trans.Trans)

Example 44 with Variables

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

the class WebServiceMetaTest method testGetFields.

@Test
public void testGetFields() throws Exception {
    WebServiceMeta webServiceMeta = new WebServiceMeta();
    webServiceMeta.setDefault();
    RowMetaInterface rmi = mock(RowMetaInterface.class);
    RowMetaInterface rmi2 = mock(RowMetaInterface.class);
    StepMeta nextStep = mock(StepMeta.class);
    IMetaStore metastore = mock(IMetaStore.class);
    Repository rep = mock(Repository.class);
    WebServiceField field1 = new WebServiceField();
    field1.setName("field1");
    field1.setWsName("field1WS");
    field1.setXsdType("string");
    WebServiceField field2 = new WebServiceField();
    field2.setName("field2");
    field2.setWsName("field2WS");
    field2.setXsdType("string");
    WebServiceField field3 = new WebServiceField();
    field3.setName("field3");
    field3.setWsName("field3WS");
    field3.setXsdType("string");
    webServiceMeta.setFieldsOut(Arrays.asList(field1, field2, field3));
    webServiceMeta.getFields(rmi, "idk", new RowMetaInterface[] { rmi2 }, nextStep, new Variables(), rep, metastore);
    verify(rmi).addValueMeta(argThat(matchValueMetaString("field1")));
    verify(rmi).addValueMeta(argThat(matchValueMetaString("field2")));
    verify(rmi).addValueMeta(argThat(matchValueMetaString("field3")));
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 45 with Variables

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

the class BaseStreamStepMetaTest method testCheckErrorsOnZeroSizeAndDuration.

@Test
public void testCheckErrorsOnZeroSizeAndDuration() {
    meta.setBatchDuration("0");
    meta.setBatchSize("0");
    ArrayList<CheckResultInterface> remarks = new ArrayList<>();
    meta.check(remarks, null, null, null, null, null, null, new Variables(), null, null);
    assertEquals(1, remarks.size());
    assertEquals("The \"Number of records\" and \"Duration\" fields can’t both be set to 0. Please set a value of 1 or higher " + "for one of the fields.", remarks.get(0).getText());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) 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