use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-kettle by pentaho.
the class RunTransServletTest method testFinishProcessingTransWithServletOutputSteps.
@Test
public void testFinishProcessingTransWithServletOutputSteps() throws Exception {
StepMetaDataCombi stepMetaDataCombi = new StepMetaDataCombi();
StepMetaInterface stepMeta = mock(StepMetaInterface.class);
when(stepMeta.passDataToServletOutput()).thenReturn(true);
stepMetaDataCombi.meta = stepMeta;
stepList.add(stepMetaDataCombi);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Thread.currentThread().sleep(2000);
return null;
}
}).when(trans).waitUntilFinished();
runTransServlet.finishProcessing(trans, out);
assertTrue(outData.toString().isEmpty());
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-metaverse by pentaho.
the class StepExternalResourceConsumerListenerTest method testCallStepExtensionPoint.
@Test
public void testCallStepExtensionPoint() throws Exception {
StepExternalResourceConsumerListener stepExtensionPoint = new StepExternalResourceConsumerListener();
stepExtensionPoint.setStepExternalResourceConsumerProvider(MetaverseTestUtils.getStepExternalResourceConsumerProvider());
StepMetaDataCombi stepCombi = mock(StepMetaDataCombi.class);
BaseStepMeta bsm = mock(BaseStepMeta.class, withSettings().extraInterfaces(StepMetaInterface.class));
stepCombi.meta = (StepMetaInterface) bsm;
stepCombi.step = mock(StepInterface.class);
stepCombi.stepMeta = mock(StepMeta.class);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
Map<Class<? extends BaseStepMeta>, Set<IStepExternalResourceConsumer>> stepConsumerMap = new StepExternalResourceConsumerProvider().getStepConsumerMap();
Set<IStepExternalResourceConsumer> consumers = new HashSet<IStepExternalResourceConsumer>();
stepConsumerMap.put(bsm.getClass(), consumers);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
IStepExternalResourceConsumer consumer = mock(IStepExternalResourceConsumer.class);
when(consumer.getResourcesFromMeta(Mockito.any())).thenReturn(Collections.emptyList());
consumers.add(consumer);
Trans mockTrans = mock(Trans.class);
when(stepCombi.step.getTrans()).thenReturn(mockTrans);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
when(consumer.isDataDriven(Mockito.any())).thenReturn(Boolean.TRUE);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pentaho-platform by pentaho.
the class KettleComponent method registerAsStepListener.
private boolean registerAsStepListener(String stepName, Trans trans) throws KettleComponentException {
boolean success = false;
try {
if (trans != null) {
List<StepMetaDataCombi> stepList = trans.getSteps();
// find the specified step
for (StepMetaDataCombi step : stepList) {
if (step.stepname.equals(stepName)) {
if (ComponentBase.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("Kettle.DEBUG_FOUND_STEP_IMPORTER"));
}
// this is the step we are looking for
if (ComponentBase.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("Kettle.DEBUG_GETTING_STEP_METADATA"));
}
RowMetaInterface row = trans.getTransMeta().getStepFields(stepName);
// create the metadata that the Pentaho result sets need
String[] fieldNames = row.getFieldNames();
String[][] columns = new String[1][fieldNames.length];
for (int column = 0; column < fieldNames.length; column++) {
columns[0][column] = fieldNames[column];
}
if (ComponentBase.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("Kettle.DEBUG_CREATING_RESULTSET_METADATA"));
}
MemoryMetaData metaData = new MemoryMetaData(columns, null);
results = new MemoryResultSet(metaData);
errorResults = new MemoryResultSet(metaData);
// add ourself as a row listener
step.step.addRowListener(this);
success = true;
break;
}
}
}
} catch (Exception e) {
throw new KettleComponentException(Messages.getInstance().getString("Kettle.ERROR_0027_ERROR_INIT_STEP", stepName), // $NON-NLS-1$
e);
}
return success;
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pdi-dataservice-server-plugin by pentaho.
the class StepOptimization method preview.
@Override
public OptimizationImpactInfo preview(DataServiceExecutor executor, PushDownOptimizationMeta meta) {
OptimizationImpactInfo info = new OptimizationImpactInfo(meta.getStepName());
Trans serviceTrans = executor.getServiceTrans();
try {
// Start up service Trans threads
serviceTrans.prepareExecution(null);
// Find the step thread and run preview
info = preview(executor, serviceTrans.findRunThread(meta.getStepName()));
// Dispose resources
for (StepMetaDataCombi stepMetaDataCombi : serviceTrans.getSteps()) {
stepMetaDataCombi.step.setOutputDone();
stepMetaDataCombi.step.dispose(stepMetaDataCombi.meta, stepMetaDataCombi.data);
stepMetaDataCombi.step.markStop();
}
} catch (Exception e) {
info.setErrorMsg(e);
}
return info;
}
use of org.pentaho.di.trans.step.StepMetaDataCombi in project pdi-dataservice-server-plugin by pentaho.
the class StepOptimizationTest method testPreview.
@Test
public void testPreview() throws Exception {
OptimizationImpactInfo impactInfo = new OptimizationImpactInfo(OPTIMIZED_STEP);
doReturn(impactInfo).when(stepOptimization).preview(executor, stepInterface);
StepMetaDataCombi stepStruct = new StepMetaDataCombi() {
{
stepMeta = mock(StepMeta.class);
stepname = OPTIMIZED_STEP;
copy = 0;
step = stepInterface;
meta = mock(StepMetaInterface.class);
data = mock(StepDataInterface.class);
}
};
when(serviceTrans.getSteps()).thenReturn(ImmutableList.of(stepStruct));
assertThat(stepOptimization.preview(executor, meta), sameInstance(impactInfo));
final InOrder inOrder = inOrder(serviceTrans, stepInterface, stepOptimization);
// Verify trans is prepared
inOrder.verify(serviceTrans).prepareExecution(null);
inOrder.verify(serviceTrans).findRunThread(OPTIMIZED_STEP);
// Run preview
inOrder.verify(stepOptimization).preview(executor, stepInterface);
// Clean up
inOrder.verify(stepInterface).setOutputDone();
inOrder.verify(stepInterface).dispose(stepStruct.meta, stepStruct.data);
inOrder.verify(stepInterface).markStop();
}
Aggregations