Search in sources :

Example 11 with SwtDialog

use of org.pentaho.ui.xul.swt.tags.SwtDialog 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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulLoader(org.pentaho.ui.xul.XulLoader) Document(org.pentaho.ui.xul.dom.Document) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) DataServiceRemapConfirmationDialogController(org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapConfirmationDialogController) InvocationOnMock(org.mockito.invocation.InvocationOnMock) XulRunner(org.pentaho.ui.xul.XulRunner) Test(org.junit.Test)

Example 12 with SwtDialog

use of org.pentaho.ui.xul.swt.tags.SwtDialog 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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DataServiceRemapNoStepsDialogController(org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapNoStepsDialogController) XulLoader(org.pentaho.ui.xul.XulLoader) Document(org.pentaho.ui.xul.dom.Document) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) InvocationOnMock(org.mockito.invocation.InvocationOnMock) XulRunner(org.pentaho.ui.xul.XulRunner) Test(org.junit.Test)

Example 13 with SwtDialog

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

the class DataServiceRemapStepChooserDialogTest 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(DataServiceRemapStepChooserDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
    DataServiceRemapStepChooserDialogController controller = mock(DataServiceRemapStepChooserDialogController.class);
    DataServiceRemapStepChooserDialog dialog = spy(new DataServiceRemapStepChooserDialog(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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DataServiceRemapStepChooserDialogController(org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapStepChooserDialogController) XulLoader(org.pentaho.ui.xul.XulLoader) Document(org.pentaho.ui.xul.dom.Document) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) InvocationOnMock(org.mockito.invocation.InvocationOnMock) XulRunner(org.pentaho.ui.xul.XulRunner) Test(org.junit.Test)

Example 14 with SwtDialog

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

the class DriverDetailsDialogTest method testOpen.

@Test
public void testOpen() throws Exception {
    DriverDetailsDialog dialog = mock(DriverDetailsDialog.class);
    doCallRealMethod().when(dialog).open();
    SwtDialog swtDialog = mock(SwtDialog.class);
    doReturn(swtDialog).when(dialog).getDialog();
    dialog.open();
    verify(dialog).getDialog();
    verify(swtDialog).show();
}
Also used : SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) Test(org.junit.Test)

Example 15 with SwtDialog

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

the class DriverDetailsDialogTest method testClose.

@Test
public void testClose() throws Exception {
    DriverDetailsDialog dialog = mock(DriverDetailsDialog.class);
    doCallRealMethod().when(dialog).close();
    SwtDialog swtDialog = mock(SwtDialog.class);
    doReturn(swtDialog).when(dialog).getDialog();
    dialog.close();
    verify(dialog).getDialog();
    verify(swtDialog).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