use of org.pentaho.di.trans.RowStepCollector in project pentaho-kettle by pentaho.
the class TextFileInputIT method testTextFileInput2.
public void testTextFileInput2() throws Exception {
KettleEnvironment.init();
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("testTextFileInput2");
PluginRegistry registry = PluginRegistry.getInstance();
// write the data that is to be read in
// by the step we are testing
String fileName = writeInputFile(2);
// Create a Text File Input step
String testFileInputName = "text file input step";
StepMeta textFileInputStep = createTextFileInputStep2(testFileInputName, fileName, registry);
transMeta.addStep(textFileInputStep);
// Create a dummy step 1 and add it to the tranMeta
String dummyStepName = "dummy step";
StepMeta dummyStep = TestUtilities.createDummyStep(dummyStepName, registry);
transMeta.addStep(dummyStep);
// create transHopMeta for the hop from text file input to the dummy step
TransHopMeta hop_textFileInputStep_dummyStep = new TransHopMeta(textFileInputStep, dummyStep);
transMeta.addTransHop(hop_textFileInputStep_dummyStep);
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
// create a row collector and add it to a row listener for the dummy step
StepInterface si = trans.getStepInterface(dummyStepName, 0);
RowStepCollector dummyRowCollector = new RowStepCollector();
si.addRowListener(dummyRowCollector);
trans.startThreads();
trans.waitUntilFinished();
// Compare the results
List<RowMetaAndData> resultRows = dummyRowCollector.getRowsWritten();
List<RowMetaAndData> goldenImageRows = createResultData2();
try {
TestUtilities.checkRows(goldenImageRows, resultRows, 0);
} catch (TestFailedException tfe) {
fail(tfe.getMessage());
}
}
use of org.pentaho.di.trans.RowStepCollector in project pentaho-kettle by pentaho.
the class UniqueRowsIT method testCaseInsensitiveNoPreviousSort.
public void testCaseInsensitiveNoPreviousSort() throws Exception {
KettleEnvironment.init();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(StepPluginType.class, im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] { "KEY" });
urm.setCaseInsensitive(new boolean[] { true });
String uniqueRowsStepPid = registry.getPluginId(StepPluginType.class, urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId(StepPluginType.class, dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for (RowMetaAndData rm : inputList) {
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseInsensitiveNoPreviousSort(), resultRows);
}
use of org.pentaho.di.trans.RowStepCollector in project pentaho-kettle by pentaho.
the class UniqueRowsIT method testSortCaseInsensitiveUniqueCaseInsensitive.
public void testSortCaseInsensitiveUniqueCaseInsensitive() throws Exception {
KettleEnvironment.init();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(StepPluginType.class, im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, im);
transMeta.addStep(injectorStep);
//
// Create a sort rows step
//
String sortRowsStepname = "sort rows step";
SortRowsMeta srm = new SortRowsMeta();
srm.setFieldName(new String[] { "KEY" });
srm.setAscending(new boolean[] { true });
srm.setCaseSensitive(new boolean[] { false });
srm.setPreSortedField(new boolean[] { false });
srm.setPrefix("SortRowsTest");
srm.setDirectory(".");
String sortRowsStepPid = registry.getPluginId(StepPluginType.class, srm);
StepMeta sortRowsStep = new StepMeta(sortRowsStepPid, sortRowsStepname, srm);
transMeta.addStep(sortRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, sortRowsStep));
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] { "KEY" });
urm.setCaseInsensitive(new boolean[] { true });
String uniqueRowsStepPid = registry.getPluginId(StepPluginType.class, urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(sortRowsStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId(StepPluginType.class, dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for (RowMetaAndData rm : inputList) {
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataSortCaseInsensitiveUniqueCaseInsensitive(), resultRows);
}
use of org.pentaho.di.trans.RowStepCollector in project pentaho-kettle by pentaho.
the class UniqueRowsIT method testCaseSensitiveNoPreviousSort.
public void testCaseSensitiveNoPreviousSort() throws Exception {
KettleEnvironment.init();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(StepPluginType.class, im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] { "KEY" });
urm.setCaseInsensitive(new boolean[] { false });
String uniqueRowsStepPid = registry.getPluginId(StepPluginType.class, urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId(StepPluginType.class, dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for (RowMetaAndData rm : inputList) {
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseSensitiveNoPreviousSort(), resultRows);
}
use of org.pentaho.di.trans.RowStepCollector in project pentaho-kettle by pentaho.
the class TextFileInputIT method testTextFileInput1.
public void testTextFileInput1() throws Exception {
KettleEnvironment.init();
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("testTextFileInput1");
PluginRegistry registry = PluginRegistry.getInstance();
// write the data that is to be read in
// by the step we are testing
String fileName = writeInputFile(1);
// create an injector step and add it to the trans meta
String injectorStepName = "injector step";
StepMeta injectorStep = TestUtilities.createInjectorStep(injectorStepName, registry);
transMeta.addStep(injectorStep);
// Create a Text File Input step
String testFileInputName = "text file input step";
StepMeta textFileInputStep = createTextFileInputStep(testFileInputName, fileName, registry);
transMeta.addStep(textFileInputStep);
// create a TransHopMeta for textFileInputStep and add it to the transMeta
TransHopMeta hopInputTextFile = new TransHopMeta(injectorStep, textFileInputStep);
transMeta.addTransHop(hopInputTextFile);
// Create a dummy step 1 and add it to the tranMeta
String dummyStepName = "dummy step";
StepMeta dummyStep = TestUtilities.createDummyStep(dummyStepName, registry);
transMeta.addStep(dummyStep);
// create transHopMeta for the hop from text file input to the dummy step
TransHopMeta hop_textFileInputStep_dummyStep = new TransHopMeta(textFileInputStep, dummyStep);
transMeta.addTransHop(hop_textFileInputStep_dummyStep);
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
// create a row collector and add it to a row listener for the dummy step
StepInterface si = trans.getStepInterface(dummyStepName, 0);
RowStepCollector dummyRowCollector = new RowStepCollector();
si.addRowListener(dummyRowCollector);
// Create a row producer for trans
RowProducer rowProducer = trans.addRowProducer(injectorStepName, 0);
trans.startThreads();
// create the filename rows
List<RowMetaAndData> inputList = createData(fileName);
Iterator<RowMetaAndData> it = inputList.iterator();
while (it.hasNext()) {
RowMetaAndData rowMetaAndData = it.next();
rowProducer.putRow(rowMetaAndData.getRowMeta(), rowMetaAndData.getData());
}
rowProducer.finished();
trans.waitUntilFinished();
// Compare the results
List<RowMetaAndData> resultRows = dummyRowCollector.getRowsWritten();
List<RowMetaAndData> goldenImageRows = createResultData1();
try {
TestUtilities.checkRows(goldenImageRows, resultRows, 5);
} catch (TestFailedException tfe) {
fail(tfe.getMessage());
}
}
Aggregations