Search in sources :

Example 1 with DataServiceRemapStepChooserDialogController

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

the class UIFactory method getRemapStepChooserDialog.

public DataServiceRemapStepChooserDialog getRemapStepChooserDialog(Shell shell, DataServiceMeta dataService, List<String> remainingStepsNames, DataServiceDelegate dataServiceDelegate) throws KettleException {
    DataServiceRemapStepChooserModel model = new DataServiceRemapStepChooserModel();
    DataServiceRemapStepChooserDialogController controller = new DataServiceRemapStepChooserDialogController(model, dataService, remainingStepsNames, dataServiceDelegate);
    return new DataServiceRemapStepChooserDialog(shell, controller);
}
Also used : DataServiceRemapStepChooserDialogController(org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapStepChooserDialogController) DataServiceRemapStepChooserModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel)

Example 2 with DataServiceRemapStepChooserDialogController

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

the class DataServiceRemapStepChooserDialogTest method testGetAction.

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

Example 3 with DataServiceRemapStepChooserDialogController

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

Aggregations

DataServiceRemapStepChooserDialogController (org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapStepChooserDialogController)3 Shell (org.eclipse.swt.widgets.Shell)2 Test (org.junit.Test)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 DataServiceRemapStepChooserModel (org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel)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