Search in sources :

Example 81 with Variables

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;
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) FilePlayListAll(org.pentaho.di.core.playlist.FilePlayListAll) AbstractFileErrorHandler(org.pentaho.di.trans.step.errorhandling.AbstractFileErrorHandler) FileErrorHandler(org.pentaho.di.trans.step.errorhandling.FileErrorHandler) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) FileInputList(org.pentaho.di.core.fileinput.FileInputList)

Example 82 with Variables

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);
}
Also used : Variables(org.pentaho.di.core.variables.Variables)

Example 83 with Variables

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());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 84 with Variables

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());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 85 with Variables

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