use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceRemapStepChooserDialog method open.
void open() throws KettleException {
SwtDialog dialog;
try {
dialog = (SwtDialog) initXul(parent, new KettleXulLoader(), new SwtXulRunner()).getElementById(XUL_DIALOG_ID);
} catch (XulException xulException) {
throw new KettleException("Failed to initialize DataServiceRemapStepChooserDialog.", xulException);
}
dialog.show();
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceDialogTest method testBuilder.
@Test
public void testBuilder() 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(model) {
@Override
protected DataServiceDialog createDialog(DataServiceDelegate delegate) {
assertThat(delegate, sameInstance(mockDelegate));
assertThat(super.createDialog(delegate), isA(DataServiceDialog.class));
return dialog;
}
};
builder.serviceStep("step");
verify(model).setServiceStep("step");
builder.serviceStep("");
builder.serviceStep(null);
verify(model, times(2)).setServiceStep("");
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);
verify(model).setServiceName("Service");
verify(model).setServiceStep("OUTPUT");
verify(model).setPushDownOptimizations(optimizations);
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 DataServiceDialogTest method testApplyOverlayException.
@Test(expected = KettleException.class)
public void testApplyOverlayException() throws Exception {
final DataServiceDialog.OptimizationOverlay overlay = mock(DataServiceDialog.OptimizationOverlay.class);
final ResourceBundle resourceBundle = mock(ResourceBundle.class);
String xulOverlay = "/path/to/overlay.xul";
dialog = new DataServiceDialog(controller, model) {
// Intercept resource bundle creation
@Override
protected ResourceBundle createResourceBundle(Class<?> packageClass) {
assertThat(packageClass, equalTo((Class) overlay.getClass()));
assertThat(super.createResourceBundle(packageClass), isA(ResourceBundle.class));
return resourceBundle;
}
};
doThrow(new XulException()).when(xulDomContainer).loadOverlay(xulOverlay, resourceBundle);
dialog.applyOverlay(overlay, xulOverlay);
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceDialogController method saveAndClose.
public void saveAndClose() throws XulException {
try {
if (dataServiceHasNoName(model)) {
return;
}
String existing = dataService != null ? dataService.getName() : null;
delegate.save(delegate.checkConflict(delegate.checkDefined(model.getDataService()), existing));
// Remove edited data service if name changed
if (dataService != null && !model.getServiceName().equals(existing)) {
delegate.removeDataService(dataService);
}
// Ensure the synchronization service is installed
delegate.createSyncService().install(model.getTransMeta());
close();
} catch (DataServiceValidationException e) {
error(getString(PKG, "DataServiceDialog.SaveError.Title"), e.getMessage());
} catch (Exception e) {
error(getString(PKG, "DataServiceDialog.SaveError.Title"), e.getMessage());
getLogChannel().logError(e.getMessage(), e);
}
}
use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.
the class StreamingOverlayTest method testApplyException.
@Test(expected = KettleException.class)
public void testApplyException() throws KettleException, InvocationTargetException, XulException {
doThrow(new XulException()).when(controller).initBindings(model);
streamingOverlay.apply(dialog);
}
Aggregations