Search in sources :

Example 46 with Variables

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

the class BaseStreamStepMetaTest method testCheckErrorsOnVariables.

@Test
public void testCheckErrorsOnVariables() {
    List<CheckResultInterface> remarks = new ArrayList<>();
    Variables space = new Variables();
    space.setVariable("something", "1000");
    meta.setBatchSize("${something}");
    meta.setBatchDuration("0");
    meta.check(remarks, null, null, null, null, null, null, space, null, null);
    assertEquals(0, remarks.size());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) Test(org.junit.Test)

Example 47 with Variables

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

the class BaseStreamStepMetaTest method testLoadReferencedObject.

@Test
public void testLoadReferencedObject() {
    BaseStreamStepMeta meta = new StuffStreamMeta();
    meta.setFileName(getClass().getResource("/org/pentaho/di/trans/subtrans-executor-sub.ktr").getPath());
    meta.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
    try {
        TransMeta subTrans = (TransMeta) meta.loadReferencedObject(0, null, null, new Variables());
        assertEquals("subtrans-executor-sub", subTrans.getName());
    } catch (KettleException e) {
        fail();
    }
    testRoundTrip(meta);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) KettleException(org.pentaho.di.core.exception.KettleException) TransMeta(org.pentaho.di.trans.TransMeta) Test(org.junit.Test)

Example 48 with Variables

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

the class TestUtils method createRamFile.

public static String createRamFile(String path, VariableSpace space) {
    if (space == null) {
        space = new Variables();
        space.initializeVariablesFrom(null);
    }
    try {
        FileObject file = KettleVFS.getFileObject("ram://" + path, space);
        file.createFile();
        return file.getName().getURI();
    } catch (FileSystemException | KettleFileException e) {
        throw new RuntimeException(e);
    }
}
Also used : Variables(org.pentaho.di.core.variables.Variables) FileSystemException(org.apache.commons.vfs2.FileSystemException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) FileObject(org.apache.commons.vfs2.FileObject)

Example 49 with Variables

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

the class TestUtils method getFileObject.

public static FileObject getFileObject(String vfsPath, VariableSpace space) {
    if (space == null) {
        space = new Variables();
        space.initializeVariablesFrom(null);
    }
    try {
        return KettleVFS.getFileObject(vfsPath, space);
    } catch (KettleFileException e) {
        throw new RuntimeException(e);
    }
}
Also used : Variables(org.pentaho.di.core.variables.Variables) KettleFileException(org.pentaho.di.core.exception.KettleFileException)

Example 50 with Variables

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

the class JobEntryTransTest method testGetTransMeta.

@Test
public void testGetTransMeta() throws KettleException {
    String param1 = "param1";
    String param2 = "param2";
    String param3 = "param3";
    String parentValue1 = "parentValue1";
    String parentValue2 = "parentValue2";
    String childValue3 = "childValue3";
    JobEntryTrans jobEntryTrans = spy(getJobEntryTrans());
    Repository rep = Mockito.mock(Repository.class);
    TransMeta meta = new TransMeta();
    meta.setVariable(param2, "childValue2 should be override");
    meta.setVariable(param3, childValue3);
    Mockito.doReturn(meta).when(rep).loadTransformation(Mockito.eq("test.ktr"), Mockito.anyObject(), Mockito.anyObject(), Mockito.anyBoolean(), Mockito.anyObject());
    VariableSpace parentSpace = new Variables();
    parentSpace.setVariable(param1, parentValue1);
    parentSpace.setVariable(param2, parentValue2);
    jobEntryTrans.setFileName("/home/admin/test.ktr");
    Mockito.doNothing().when(jobEntryTrans).logBasic(Mockito.anyString());
    jobEntryTrans.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
    TransMeta transMeta;
    jobEntryTrans.setPassingAllParameters(false);
    transMeta = jobEntryTrans.getTransMeta(rep, null, parentSpace);
    Assert.assertEquals(null, transMeta.getVariable(param1));
    Assert.assertEquals(parentValue2, transMeta.getVariable(param2));
    Assert.assertEquals(childValue3, transMeta.getVariable(param3));
    jobEntryTrans.setPassingAllParameters(true);
    transMeta = jobEntryTrans.getTransMeta(rep, null, parentSpace);
    Assert.assertEquals(parentValue1, transMeta.getVariable(param1));
    Assert.assertEquals(parentValue2, transMeta.getVariable(param2));
    Assert.assertEquals(childValue3, transMeta.getVariable(param3));
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) VariableSpace(org.pentaho.di.core.variables.VariableSpace) TransMeta(org.pentaho.di.trans.TransMeta) 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