use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class TextFileInputTest method createDataObject.
private TextFileInputData createDataObject(String file, String separator, String... outputFields) throws Exception {
TextFileInputData data = new TextFileInputData();
data.files = new FileInputList();
data.files.addFile(KettleVFS.getFileObject(file));
data.separator = separator;
data.outputRowMeta = new RowMeta();
if (outputFields != null) {
for (String field : outputFields) {
data.outputRowMeta.addValueMeta(new ValueMetaString(field));
}
}
data.dataErrorLineHandler = mock(FileErrorHandler.class);
data.fileFormatType = TextFileInputMeta.FILE_FORMAT_UNIX;
data.filterProcessor = new TextFileFilterProcessor(new TextFileFilter[0], new Variables());
data.filePlayList = new FilePlayListAll();
return data;
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class BaseFixedParsingTest method setFields.
/**
* Declare fields for test.
*/
protected void setFields(FixedFileInputField... fields) throws Exception {
meta.setFieldDefinition(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 WebServiceMetaTest method testCheck.
@Test
public void testCheck() throws Exception {
WebServiceMeta webServiceMeta = new WebServiceMeta();
TransMeta transMeta = mock(TransMeta.class);
StepMeta stepMeta = mock(StepMeta.class);
RowMetaInterface prev = mock(RowMetaInterface.class);
RowMetaInterface info = mock(RowMetaInterface.class);
Repository rep = mock(Repository.class);
IMetaStore metastore = mock(IMetaStore.class);
String[] input = { "one" };
ArrayList<CheckResultInterface> remarks = new ArrayList<>();
webServiceMeta.check(remarks, transMeta, stepMeta, null, input, null, info, new Variables(), rep, metastore);
assertEquals(2, remarks.size());
assertEquals("Not receiving any fields from previous steps!", remarks.get(0).getText());
assertEquals("Step is receiving info from other steps.", remarks.get(1).getText());
remarks.clear();
webServiceMeta.setInFieldArgumentName("ifan");
when(prev.size()).thenReturn(2);
webServiceMeta.check(remarks, transMeta, stepMeta, prev, new String[] {}, null, info, new Variables(), rep, metastore);
assertEquals(2, remarks.size());
assertEquals("Step is connected to previous one, receiving 2 fields", remarks.get(0).getText());
assertEquals("No input received from other steps!", remarks.get(1).getText());
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class ZipFileMetaTest method testCheck.
@Test
public void testCheck() {
ZipFileMeta zipFileMeta = new ZipFileMeta();
zipFileMeta.setDefault();
TransMeta transMeta = mock(TransMeta.class);
StepMeta stepInfo = mock(StepMeta.class);
RowMetaInterface prev = mock(RowMetaInterface.class);
Repository repos = mock(Repository.class);
IMetaStore metastore = mock(IMetaStore.class);
RowMetaInterface info = mock(RowMetaInterface.class);
ArrayList<CheckResultInterface> remarks = new ArrayList<>();
zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(2, remarks.size());
assertEquals("Source Filename field is missing!", remarks.get(0).getText());
assertEquals("Step is receiving info from other steps.", remarks.get(1).getText());
remarks = new ArrayList<>();
zipFileMeta = new ZipFileMeta();
zipFileMeta.setDynamicSourceFileNameField("sourceFileField");
zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[0], new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(2, remarks.size());
assertEquals("Target Filename field was specified", remarks.get(0).getText());
assertEquals("No input received from other steps!", remarks.get(1).getText());
}
use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.
the class BaseStreamStepMetaTest method testCheckErrorsOnNaN.
@Test
public void testCheckErrorsOnNaN() throws Exception {
List<CheckResultInterface> remarks = new ArrayList<>();
meta.setBatchDuration("blah");
meta.setBatchSize("blah");
meta.check(remarks, null, null, null, null, null, null, new Variables(), null, null);
assertEquals(2, remarks.size());
assertEquals(CheckResultInterface.TYPE_RESULT_ERROR, remarks.get(0).getType());
assertEquals("The \"Duration\" field is using a non-numeric value. Please set a numeric value.", remarks.get(0).getText());
assertEquals(CheckResultInterface.TYPE_RESULT_ERROR, remarks.get(1).getType());
assertEquals("The \"Number of records\" field is using a non-numeric value. Please set a numeric value.", remarks.get(1).getText());
}
Aggregations