Search in sources :

Example 21 with XulException

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();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 22 with XulException

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));
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) PushDownFactory(org.pentaho.di.trans.dataservice.optimization.PushDownFactory) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) Test(org.junit.Test)

Example 23 with 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);
}
Also used : XulException(org.pentaho.ui.xul.XulException) ResourceBundle(java.util.ResourceBundle) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 24 with XulException

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);
    }
}
Also used : BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString) XulException(org.pentaho.ui.xul.XulException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataServiceValidationException(org.pentaho.di.trans.dataservice.serialization.DataServiceValidationException) DataServiceValidationException(org.pentaho.di.trans.dataservice.serialization.DataServiceValidationException)

Example 25 with XulException

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);
}
Also used : XulException(org.pentaho.ui.xul.XulException) Test(org.junit.Test)

Aggregations

XulException (org.pentaho.ui.xul.XulException)60 KettleException (org.pentaho.di.core.exception.KettleException)20 Test (org.junit.Test)11 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)10 XulComponent (org.pentaho.ui.xul.XulComponent)9 Shell (org.eclipse.swt.widgets.Shell)7 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)7 SwtXulRunner (org.pentaho.ui.xul.swt.SwtXulRunner)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)6 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)6 XulRunner (org.pentaho.ui.xul.XulRunner)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Document (org.pentaho.ui.xul.dom.Document)4 ResourceBundle (java.util.ResourceBundle)3 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 XulLoader (org.pentaho.ui.xul.XulLoader)3 SwtBindingFactory (org.pentaho.ui.xul.swt.SwtBindingFactory)3