Search in sources :

Example 1 with DataServiceRemapConfirmationDialogController

use of org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapConfirmationDialogController in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRemapConfirmationDialogTest method testGetAction.

@Test
public void testGetAction() {
    DataServiceRemapConfirmationDialogController controller = mock(DataServiceRemapConfirmationDialogController.class);
    when(controller.getAction()).thenReturn(REMAP);
    DataServiceRemapConfirmationDialog dialog = new DataServiceRemapConfirmationDialog(mock(Shell.class), controller);
    Assert.assertEquals(REMAP, dialog.getAction());
    verify(controller).getAction();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DataServiceRemapConfirmationDialogController(org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapConfirmationDialogController) Test(org.junit.Test)

Example 2 with DataServiceRemapConfirmationDialogController

use of org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapConfirmationDialogController 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)

Aggregations

Shell (org.eclipse.swt.widgets.Shell)2 Test (org.junit.Test)2 DataServiceRemapConfirmationDialogController (org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapConfirmationDialogController)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1 KettleException (org.pentaho.di.core.exception.KettleException)1 XulException (org.pentaho.ui.xul.XulException)1 XulLoader (org.pentaho.ui.xul.XulLoader)1 XulRunner (org.pentaho.ui.xul.XulRunner)1 Document (org.pentaho.ui.xul.dom.Document)1 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)1