Search in sources :

Example 16 with SwtDialog

use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceDialogControllerTest method testShowDriverDetails.

@Test
public void testShowDriverDetails() {
    DataServiceDelegate delegate = mock(DataServiceDelegate.class);
    controller = spy(new DataServiceDialogController(null, delegate));
    SwtDialog dialog = mock(SwtDialog.class);
    doReturn(dialog).when(controller).getDialog();
    Shell shell = mock(Shell.class);
    doReturn(shell).when(dialog).getShell();
    doCallRealMethod().when(controller).showDriverDetailsDialog();
    controller.showDriverDetailsDialog();
    verify(delegate).showDriverDetailsDialog(shell);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) DataServiceDelegate(org.pentaho.di.trans.dataservice.ui.DataServiceDelegate) Test(org.junit.Test)

Example 17 with SwtDialog

use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRemapStepChooserDialogControllerTest method testRemap.

@Test
public void testRemap() throws Exception {
    DataServiceRemapStepChooserModel model = mock(DataServiceRemapStepChooserModel.class);
    DataServiceMeta dataService = mock(DataServiceMeta.class);
    List<String> stepNames = Arrays.asList("step1", "step2");
    DataServiceDelegate delegate = mock(DataServiceDelegate.class);
    SwtDialog dialog = mock(SwtDialog.class);
    when(model.getServiceStep()).thenReturn("step2");
    doNothing().doThrow(Exception.class).when(delegate).save(any(DataServiceMeta.class));
    DataServiceRemapStepChooserDialogController controller = spy(new DataServiceRemapStepChooserDialogController(model, dataService, stepNames, delegate));
    doReturn(dialog).when(controller).getDialog();
    controller.remap();
    verify(dataService).setStepname("step2");
    verify(delegate).save(same(dataService));
    Assert.assertEquals(DataServiceRemapStepChooserDialog.Action.REMAP, controller.getAction());
    controller.remap();
    verify(delegate).showError(anyString(), anyString());
    Assert.assertEquals(DataServiceRemapStepChooserDialog.Action.CANCEL, controller.getAction());
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) DataServiceRemapStepChooserModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel) DataServiceDelegate(org.pentaho.di.trans.dataservice.ui.DataServiceDelegate) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 18 with SwtDialog

use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.

the class DriverDetailsDialogControllerTest method testGetDialog.

@Test
public void testGetDialog() throws Exception {
    doCallRealMethod().when(controller).getDialog();
    SwtDialog dialog = mock(SwtDialog.class);
    doReturn(dialog).when(controller).getElementById(DriverDetailsDialog.XUL_DIALOG_ID);
    assertThat(dialog, is(sameInstance(controller.getDialog())));
}
Also used : SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) Test(org.junit.Test)

Example 19 with SwtDialog

use of org.pentaho.ui.xul.swt.tags.SwtDialog in project pdi-dataservice-server-plugin by pentaho.

the class DriverDetailsDialogControllerTest method testCloseDisposesDialog.

@Test
public void testCloseDisposesDialog() throws Exception {
    doCallRealMethod().when(controller).close();
    SwtDialog dialog = mock(SwtDialog.class);
    doReturn(dialog).when(controller).getDialog();
    controller.close();
    verify(dialog).dispose();
}
Also used : SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) Test(org.junit.Test)

Aggregations

SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)19 Test (org.junit.Test)13 XulException (org.pentaho.ui.xul.XulException)7 KettleException (org.pentaho.di.core.exception.KettleException)6 Document (org.pentaho.ui.xul.dom.Document)5 Shell (org.eclipse.swt.widgets.Shell)4 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)4 SwtXulRunner (org.pentaho.ui.xul.swt.SwtXulRunner)4 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 DataServiceDelegate (org.pentaho.di.trans.dataservice.ui.DataServiceDelegate)3 XulLoader (org.pentaho.ui.xul.XulLoader)3 XulRunner (org.pentaho.ui.xul.XulRunner)3 FileNotFoundException (java.io.FileNotFoundException)1 AccessDeniedException (java.nio.file.AccessDeniedException)1 NotDirectoryException (java.nio.file.NotDirectoryException)1 Matchers.anyString (org.mockito.Matchers.anyString)1 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)1 DataServiceAlreadyExistsException (org.pentaho.di.trans.dataservice.serialization.DataServiceAlreadyExistsException)1