use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class LoadFileInputTest method setup.
@Before
public void setup() throws FileSystemException {
fs = VFS.getManager();
filesPath = '/' + this.getClass().getPackage().getName().replace('.', '/') + "/files/";
transName = "LoadFileInput";
transMeta = new TransMeta();
transMeta.setName(transName);
trans = new Trans(transMeta);
stepMetaInterface = spy(new LoadFileInputMeta());
stepInputFiles = new FileInputList();
Mockito.doReturn(stepInputFiles).when(stepMetaInterface).getFiles(any(VariableSpace.class));
String stepId = PluginRegistry.getInstance().getPluginId(StepPluginType.class, stepMetaInterface);
stepMeta = new StepMeta(stepId, "Load File Input", stepMetaInterface);
transMeta.addStep(stepMeta);
stepDataInterface = new LoadFileInputData();
stepCopyNr = 0;
stepLoadFileInput = new LoadFileInput(stepMeta, stepDataInterface, stepCopyNr, transMeta, trans);
assertSame(stepMetaInterface, stepMeta.getStepMetaInterface());
runtimeSMI = stepMetaInterface;
runtimeSDI = runtimeSMI.getStepData();
inputField = new LoadFileInputField();
((LoadFileInputMeta) runtimeSMI).setInputFields(new LoadFileInputField[] { inputField });
stepLoadFileInput.init(runtimeSMI, runtimeSDI);
}
use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class TransMetaConverterTest method testDisabledHops.
@Test
public void testDisabledHops() {
TransMeta trans = new TransMeta();
StepMeta start = new StepMeta("Start", stepMetaInterface);
trans.addStep(start);
StepMeta withEnabledHop = new StepMeta("WithEnabledHop", stepMetaInterface);
trans.addStep(withEnabledHop);
StepMeta withDisabledHop = new StepMeta("WithDisabledHop", stepMetaInterface);
trans.addStep(withDisabledHop);
StepMeta shouldStay = new StepMeta("ShouldStay", stepMetaInterface);
trans.addStep(shouldStay);
StepMeta shouldNotStay = new StepMeta("ShouldNotStay", stepMetaInterface);
trans.addStep(shouldNotStay);
StepMeta withEnabledAndDisabledHops = new StepMeta("WithEnabledAndDisabledHops", stepMetaInterface);
trans.addStep(withEnabledAndDisabledHops);
StepMeta afterEnabledDisabled = new StepMeta("AfterEnabledDisabled", stepMetaInterface);
trans.addStep(afterEnabledDisabled);
trans.addTransHop(new TransHopMeta(start, withEnabledHop));
trans.addTransHop(new TransHopMeta(start, withDisabledHop, false));
trans.addTransHop(new TransHopMeta(withEnabledHop, shouldStay));
trans.addTransHop(new TransHopMeta(withDisabledHop, shouldStay));
trans.addTransHop(new TransHopMeta(withDisabledHop, shouldNotStay));
trans.addTransHop(new TransHopMeta(start, withEnabledAndDisabledHops));
trans.addTransHop(new TransHopMeta(withEnabledHop, withEnabledAndDisabledHops, false));
trans.addTransHop(new TransHopMeta(withEnabledAndDisabledHops, afterEnabledDisabled));
Transformation transformation = TransMetaConverter.convert(trans);
List<String> steps = transformation.getOperations().stream().map(op -> op.getId()).collect(Collectors.toList());
assertThat("Only 5 ops should exist", steps.size(), is(5));
assertThat(steps, hasItems("Start", "WithEnabledHop", "ShouldStay", "WithEnabledAndDisabledHops", "AfterEnabledDisabled"));
List<String> hops = transformation.getHops().stream().map(hop -> hop.getId()).collect(Collectors.toList());
assertThat("Only 4 hops should exist", hops.size(), is(4));
assertThat(hops, hasItems("Start -> WithEnabledHop", "WithEnabledHop -> ShouldStay", "Start -> WithEnabledAndDisabledHops", "WithEnabledAndDisabledHops -> AfterEnabledDisabled"));
}
use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class DeleteMetaTest method setUp.
@Before
public void setUp() {
TransMeta transMeta = new TransMeta();
transMeta.setName("delete1");
Map<String, String> vars = new HashMap<String, String>();
vars.put("max.sz", "10");
transMeta.injectVariables(vars);
dmi = new DeleteMeta();
dd = new DeleteData();
PluginRegistry plugReg = PluginRegistry.getInstance();
String deletePid = plugReg.getPluginId(StepPluginType.class, dmi);
stepMeta = new StepMeta(deletePid, "delete", dmi);
Trans trans = new Trans(transMeta);
transMeta.addStep(stepMeta);
del = new Delete(stepMeta, dd, 1, transMeta, trans);
del.copyVariablesFrom(transMeta);
}
use of org.pentaho.di.trans.Trans 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.trans.Trans in project pentaho-kettle by pentaho.
the class TransExecutorUnitTest method setUp.
@Before
public void setUp() throws Exception {
executor = StepMockUtil.getStep(TransExecutor.class, TransExecutorMeta.class, "TransExecutorUnitTest");
executor = spy(executor);
TransMeta internalTransMeta = mock(TransMeta.class);
doReturn(internalTransMeta).when(executor).loadExecutorTransMeta();
internalTrans = spy(new Trans());
internalTrans.setLog(mock(LogChannelInterface.class));
doNothing().when(internalTrans).prepareExecution(any(String[].class));
doNothing().when(internalTrans).startThreads();
doNothing().when(internalTrans).waitUntilFinished();
doNothing().when(executor).discardLogLines(any(TransExecutorData.class));
doReturn(internalTrans).when(executor).createInternalTrans();
internalResult = new Result();
doReturn(internalResult).when(internalTrans).getResult();
meta = new TransExecutorMeta();
data = new TransExecutorData();
}
Aggregations