use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class TransTest method testCleanup_WithSteps.
@Test
public void testCleanup_WithSteps() throws Exception {
StepInterface stepMock1 = mock(StepInterface.class);
StepInterface stepMock2 = mock(StepInterface.class);
StepDataInterface stepDataMock1 = mock(StepDataInterface.class);
StepDataInterface stepDataMock2 = mock(StepDataInterface.class);
StepMeta stepMetaMock1 = mock(StepMeta.class);
StepMeta stepMetaMock2 = mock(StepMeta.class);
// A step that is already disposed
when(stepDataMock1.isDisposed()).thenReturn(true);
// A step not yet disposed
when(stepDataMock2.isDisposed()).thenReturn(false);
trans.setSteps(of(combi(stepMock1, stepDataMock1, stepMetaMock1), combi(stepMock2, stepDataMock2, stepMetaMock2)));
// this should work (no exception thrown)
trans.cleanup();
// The isDisposed method is always invoked
verify(stepDataMock1).isDisposed();
verify(stepDataMock2).isDisposed();
// Only 'stepDataMock2' is to be disposed
verify(stepMock1, times(0)).dispose(any(StepMetaInterface.class), any(StepDataInterface.class));
verify(stepMock2, times(1)).dispose(any(StepMetaInterface.class), any(StepDataInterface.class));
// The cleanup method is always invoked
verify(stepMock1).cleanup();
verify(stepMock2).cleanup();
}
use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class TransTest method safeStopLetsNonInputStepsKeepRunning.
@Test
public void safeStopLetsNonInputStepsKeepRunning() throws Exception {
StepInterface stepMock1 = mock(StepInterface.class);
StepInterface stepMock2 = mock(StepInterface.class);
StepDataInterface stepDataMock1 = mock(StepDataInterface.class);
StepDataInterface stepDataMock2 = mock(StepDataInterface.class);
StepMeta stepMetaMock1 = mock(StepMeta.class);
StepMeta stepMetaMock2 = mock(StepMeta.class);
trans.setSteps(of(combi(stepMock1, stepDataMock1, stepMetaMock1), combi(stepMock2, stepDataMock2, stepMetaMock2)));
doReturn(emptyList()).when(meta).findPreviousSteps(stepMetaMock1, true);
// stepMeta2 will have stepMeta as previous, so is not an input step
doReturn(of(stepMetaMock1)).when(meta).findPreviousSteps(stepMetaMock2, true);
trans.safeStop();
verifyStopped(stepMock1, 1);
// non input step shouldn't have stop called
verifyStopped(stepMock2, 0);
verify(trans).notifyStoppedListeners();
}
use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class StepWithMappingMetaTest method testExportResources.
@SuppressWarnings("unchecked")
@Test
@PrepareForTest(StepWithMappingMeta.class)
public void testExportResources() throws Exception {
StepWithMappingMeta stepWithMappingMeta = spy(new StepWithMappingMeta() {
@Override
public void setDefault() {
}
@Override
public StepDataInterface getStepData() {
return null;
}
@Override
public StepInterface getStep(StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta, Trans trans) {
return null;
}
});
String testName = "test";
PowerMockito.mockStatic(StepWithMappingMeta.class);
when(StepWithMappingMeta.loadMappingMeta(any(), any(), any(), any())).thenReturn(transMeta);
when(transMeta.exportResources(any(), anyMap(), any(), any(), any())).thenReturn(testName);
stepWithMappingMeta.exportResources(null, null, null, null, null);
verify(transMeta).setFilename("${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + testName);
verify(stepWithMappingMeta).setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
}
use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class TransTest method testGetEnded_withSteps.
@Test
public void testGetEnded_withSteps() {
List<StepMetaDataCombi> steps = new ArrayList<>();
int ended = 0;
// Steps with all possible status (and still running).
// Finished, Halted, or Stopped (three in total) should be counted.
ended += 3;
for (BaseStepData.StepExecutionStatus status : BaseStepData.StepExecutionStatus.values()) {
StepInterface stepMock = mock(StepInterface.class);
StepDataInterface stepDataMock = mock(StepDataInterface.class);
StepMeta stepMetaMock = mock(StepMeta.class);
doReturn(true).when(stepMock).isRunning();
doReturn(status).when(stepDataMock).getStatus();
steps.add(combi(stepMock, stepDataMock, stepMetaMock));
}
// Step not running (also to be counted)
++ended;
StepInterface stepMock = mock(StepInterface.class);
doReturn(false).when(stepMock).isRunning();
steps.add(combi(stepMock, mock(StepDataInterface.class), mock(StepMeta.class)));
// Add created steps
trans.setSteps(steps);
// A total of four (4) steps should be counted as ended.
assertEquals(ended, trans.getEnded());
}
use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.
the class UnivariateStatsMetaTest method testGetStep.
@Test
public void testGetStep() {
StepMeta mockStepMeta = mock(StepMeta.class);
when(mockStepMeta.getName()).thenReturn("testName");
StepDataInterface mockStepDataInterface = mock(StepDataInterface.class);
int cnr = 10;
TransMeta mockTransMeta = mock(TransMeta.class);
Trans mockTrans = mock(Trans.class);
when(mockTransMeta.findStep("testName")).thenReturn(mockStepMeta);
StepInterface step = new UnivariateStatsMeta().getStep(mockStepMeta, mockStepDataInterface, cnr, mockTransMeta, mockTrans);
assertTrue("Expected Step to be instanceof " + UnivariateStats.class, step instanceof UnivariateStats);
}
Aggregations