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