use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DriverDetailsDialog method initXul.
Document initXul(Composite parent, AbstractXulLoader xulLoader, XulRunner xulRunner) throws KettleException {
try {
xulLoader.setOuterContext(parent);
xulLoader.registerClassLoader(getClass().getClassLoader());
XulDomContainer container = xulLoader.loadXul(XUL_DIALOG_PATH, resourceBundle);
container.addEventHandler(controller);
xulRunner.addContainer(container);
xulRunner.initialize();
return container.getDocumentRoot();
} catch (XulException xulException) {
throw new KettleException("Failed to initialize DriverDetailsDialog.", xulException);
}
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceDelegateTest method testShowDriverDetailsDialog.
@Test
public void testShowDriverDetailsDialog() throws KettleException, XulException {
DriverDetailsDialog dialog = mock(DriverDetailsDialog.class);
doReturn(dialog).when(uiFactory).getDriverDetailsDialog(shell);
delegate.showDriverDetailsDialog();
verify(dialog).open();
Exception e = new RuntimeException();
doThrow(e).when(dialog).open();
delegate.showDriverDetailsDialog();
verify(logChannel).logError(anyString(), same(e));
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceDialogTest method testBuilderTransMeta.
@Test
public void testBuilderTransMeta() throws Exception {
final DataServiceDelegate mockDelegate = mock(DataServiceDelegate.class);
final DataServiceDialog dialog = mock(DataServiceDialog.class);
when(dialog.getController()).thenReturn(controller);
// Intercept actual creation so we can inject our mock
DataServiceDialog.Builder builder = new DataServiceDialog.Builder(transMeta) {
@Override
protected DataServiceDialog createDialog(DataServiceDelegate delegate) {
assertThat(delegate, sameInstance(mockDelegate));
assertThat(super.createDialog(delegate), isA(DataServiceDialog.class));
return dialog;
}
};
builder.serviceStep("step");
builder.serviceStep("");
builder.serviceStep(null);
DataServiceMeta dataService = mock(DataServiceMeta.class);
when(dataService.getName()).thenReturn("Service");
when(dataService.getStepname()).thenReturn("OUTPUT");
ArrayList<PushDownOptimizationMeta> optimizations = Lists.newArrayList(mock(PushDownOptimizationMeta.class));
when(dataService.getPushDownOptimizationMeta()).thenReturn(optimizations);
builder.edit(dataService);
Shell shell = mock(Shell.class);
ArrayList<PushDownFactory> factories = Lists.newArrayList(mock(PushDownFactory.class));
when(mockDelegate.getShell()).thenReturn(shell);
when(mockDelegate.getPushDownFactories()).thenReturn(factories);
assertThat(builder.build(mockDelegate), sameInstance(dialog));
verify(controller).setDataService(dataService);
verify(dialog).loadXul(same(shell), any(KettleXulLoader.class), any(SwtXulRunner.class));
verify(dialog).initOptimizations(factories);
Throwable xulException = new XulException();
when(dialog.loadXul(same(shell), any(KettleXulLoader.class), any(SwtXulRunner.class))).thenThrow(xulException);
try {
builder.build(mockDelegate);
fail("Expected exception was not thrown");
} catch (KettleException e) {
assertThat(e.getCause(), equalTo(xulException));
}
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapConfirmationDialogTest method testOpen.
@Test
public void testOpen() throws XulException, KettleException {
Shell shell = mock(Shell.class);
final Document document = mock(Document.class);
SwtDialog swtDialog = mock(SwtDialog.class);
when(document.getElementById(DataServiceRemapConfirmationDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
DataServiceRemapConfirmationDialogController controller = mock(DataServiceRemapConfirmationDialogController.class);
DataServiceRemapConfirmationDialog dialog = spy(new DataServiceRemapConfirmationDialog(shell, controller));
doAnswer(new Answer() {
private int invocations = 0;
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
if (invocations == 0) {
invocations++;
return document;
} else {
throw new XulException("");
}
}
}).when(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
dialog.open();
verify(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
verify(swtDialog).show();
try {
dialog.open();
} catch (Exception e) {
Assert.assertTrue(e instanceof KettleException);
}
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapNoStepsDialogTest method testOpen.
@Test
public void testOpen() throws XulException, KettleException {
Shell shell = mock(Shell.class);
final Document document = mock(Document.class);
SwtDialog swtDialog = mock(SwtDialog.class);
when(document.getElementById(DataServiceRemapNoStepsDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
DataServiceRemapNoStepsDialogController controller = mock(DataServiceRemapNoStepsDialogController.class);
DataServiceRemapNoStepsDialog dialog = spy(new DataServiceRemapNoStepsDialog(shell, controller));
doAnswer(new Answer() {
private int invocations = 0;
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
if (invocations == 0) {
invocations++;
return document;
} else {
throw new XulException("");
}
}
}).when(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
dialog.open();
verify(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
verify(swtDialog).show();
try {
dialog.open();
} catch (Exception e) {
Assert.assertTrue(e instanceof KettleException);
}
}
Aggregations