Search in sources :

Example 1 with DataServiceRemapStepChooserModel

use of org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel 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 DataServiceRemapStepChooserModel

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

the class DataServiceRemapStepChooserDialogControllerTest method testInit.

@Test
public void testInit() throws InvocationTargetException, XulException {
    DataServiceRemapStepChooserModel model = mock(DataServiceRemapStepChooserModel.class);
    DataServiceMeta dataService = mock(DataServiceMeta.class);
    List<String> stepNames = Arrays.asList("step1");
    DataServiceDelegate delegate = mock(DataServiceDelegate.class);
    final SwtLabel label = mock(SwtLabel.class);
    final SwtListbox listbox = mock(SwtListbox.class);
    BindingFactory bindingFactory = mock(BindingFactory.class);
    when(bindingFactory.createBinding(same(model), anyString(), any(XulComponent.class), anyString())).thenReturn(mock(Binding.class));
    DataServiceRemapStepChooserDialogController controller = spy(new DataServiceRemapStepChooserDialogController(model, dataService, stepNames, delegate));
    doAnswer(new Answer() {

        private Object[] returnValues = { label, listbox };

        int invocations = 0;

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return returnValues[invocations++];
        }
    }).when(controller).getElementById(anyString());
    doReturn(bindingFactory).when(controller).getBindingFactory();
    controller.init();
    verify(label).setValue(anyString());
    verify(listbox).setElements(same(stepNames));
    verify(bindingFactory).createBinding(same(model), anyString(), same(listbox), anyString());
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) SwtListbox(org.pentaho.ui.xul.swt.tags.SwtListbox) Matchers.anyString(org.mockito.Matchers.anyString) SwtLabel(org.pentaho.ui.xul.swt.tags.SwtLabel) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DataServiceRemapStepChooserModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel) DataServiceDelegate(org.pentaho.di.trans.dataservice.ui.DataServiceDelegate) XulComponent(org.pentaho.ui.xul.XulComponent) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) Test(org.junit.Test)

Example 3 with DataServiceRemapStepChooserModel

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

Aggregations

DataServiceRemapStepChooserModel (org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel)3 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)2 DataServiceDelegate (org.pentaho.di.trans.dataservice.ui.DataServiceDelegate)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1 DataServiceRemapStepChooserDialogController (org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapStepChooserDialogController)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 Binding (org.pentaho.ui.xul.binding.Binding)1 BindingFactory (org.pentaho.ui.xul.binding.BindingFactory)1 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)1 SwtLabel (org.pentaho.ui.xul.swt.tags.SwtLabel)1 SwtListbox (org.pentaho.ui.xul.swt.tags.SwtListbox)1