Search in sources :

Example 11 with DataServiceDelegate

use of org.pentaho.di.trans.dataservice.ui.DataServiceDelegate 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 12 with DataServiceDelegate

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

the class TransOpenedExtensionPointPluginTest method setUp.

@Before
public void setUp() throws Exception {
    DataServiceContext context = mock(DataServiceContext.class);
    DataServiceDelegate delegate = mock(DataServiceDelegate.class);
    when(context.getDataServiceDelegate()).thenReturn(delegate);
    when(delegate.createSyncService()).thenReturn(service);
    extensionPointPlugin = new TransOpenedExtensionPointPlugin(context);
}
Also used : DataServiceContext(org.pentaho.di.trans.dataservice.DataServiceContext) DataServiceDelegate(org.pentaho.di.trans.dataservice.ui.DataServiceDelegate) Before(org.junit.Before)

Aggregations

DataServiceDelegate (org.pentaho.di.trans.dataservice.ui.DataServiceDelegate)12 Test (org.junit.Test)11 DataServiceContext (org.pentaho.di.trans.dataservice.DataServiceContext)6 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 DataServiceResolver (org.pentaho.di.trans.dataservice.resolvers.DataServiceResolver)5 MetastoreLocator (org.pentaho.osgi.metastore.locator.api.MetastoreLocator)5 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)5 TransMeta (org.pentaho.di.trans.TransMeta)4 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)4 ModelAnnotationGroup (org.pentaho.agilebi.modeler.models.annotations.ModelAnnotationGroup)3 URL (java.net.URL)2 Shell (org.eclipse.swt.widgets.Shell)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 CreateAttribute (org.pentaho.agilebi.modeler.models.annotations.CreateAttribute)2 TransHopMeta (org.pentaho.di.trans.TransHopMeta)2 DataServiceRemapStepChooserModel (org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 Document (org.w3c.dom.Document)2