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);
}
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" } });
}
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());
}
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")));
}
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());
}
Aggregations