use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class MetaInjectTest method testTransWaitsForListenersToFinish.
@Test
public void testTransWaitsForListenersToFinish() throws Exception {
doReturn(new String[] {}).when(transMeta).getPrevStepNames(any(StepMeta.class));
data.stepInjectionMetasMap = new HashMap<>();
data.stepInjectionMap = new HashMap<>();
data.transMeta = new TransMeta();
meta.setNoExecution(false);
Trans injectTrans = mock(Trans.class);
doReturn(injectTrans).when(metaInject).createInjectTrans();
when(injectTrans.isFinished()).thenReturn(true);
Result result = mock(Result.class);
when(injectTrans.getResult()).thenReturn(result);
metaInject.processRow(meta, data);
verify(injectTrans).waitUntilFinished();
}
use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class AccessInputDialog method preview.
// Preview the data
private void preview() {
try {
// Create the Access input step
AccessInputMeta oneMeta = new AccessInputMeta();
getInfo(oneMeta);
// check if the path is given
if (!checkInputTableName(oneMeta)) {
return;
}
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "AccessInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "AccessInputDialog.NumberRows.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "AccessInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "AccessInputDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class RowGeneratorUnitTest method doesNotWriteRowOnTimeWhenStopped.
@Test
public void doesNotWriteRowOnTimeWhenStopped() throws KettleException, InterruptedException {
TransMeta transMeta = new TransMeta(getClass().getResource("safe-stop.ktr").getPath());
Trans trans = new Trans(transMeta);
trans.prepareExecution(new String[] {});
trans.getSteps().get(1).step.addRowListener(new RowAdapter() {
@Override
public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
trans.safeStop();
}
});
trans.startThreads();
trans.waitUntilFinished();
assertEquals(1, trans.getSteps().get(0).step.getLinesWritten());
assertEquals(1, trans.getSteps().get(1).step.getLinesRead());
}
use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class ScriptValueAddFunctions_SetVariableScopeTest method setSystemScopeVariable_NoParent.
@Test
public void setSystemScopeVariable_NoParent() {
Trans trans = createTrans();
Assert.assertNull(System.getProperty(VARIABLE_NAME));
try {
ScriptValuesAddedFunctions.setSystemScopeVariable(trans, VARIABLE_NAME, VARIABLE_VALUE);
Assert.assertEquals(System.getProperty(VARIABLE_NAME), VARIABLE_VALUE);
verify(trans).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
} finally {
System.clearProperty(VARIABLE_NAME);
}
}
use of org.pentaho.di.trans.Trans in project pentaho-kettle by pentaho.
the class ScriptValueAddFunctions_SetVariableScopeTest method setGrandParentScopeVariable_TwoLevelHierarchy.
@Test
public void setGrandParentScopeVariable_TwoLevelHierarchy() {
Trans parent = createTrans();
Trans child = createTrans(parent);
ScriptValuesAddedFunctions.setGrandParentScopeVariable(child, VARIABLE_NAME, VARIABLE_VALUE);
verify(child).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
verify(parent).setVariable(eq(VARIABLE_NAME), eq(VARIABLE_VALUE));
}
Aggregations