DataServiceStepMenuExtension implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException { StepMenuExtension extension = (StepMenuExtension) object; TransMeta transMeta = extension.getTransGraph().getTransMeta(); StepMeta stepMeta = extension.getTransGraph().getCurrentStep(); XulMenupopup menu = extension.getMenu(); DataServiceMeta dataService = metaStoreUtil.getDataServiceByStepName( transMeta, stepMeta.getName() ); Boolean hasDataService = dataService != null && dataService.isUserDefined(); menu.getElementById( "dataservices-new" ).setDisabled( hasDataService ); menu.getElementById( "dataservices-edit" ).setDisabled( !hasDataService ); menu.getElementById( "dataservices-delete" ).setDisabled( !hasDataService ); menu.getElementById( "dataservices-test" ).setDisabled( !hasDataService ); } DataServiceStepMenuExtension( DataServiceContext context ); @Override void callExtensionPoint( LogChannelInterface log, Object object );  }
@Test public void testCallExtensionPoint() throws Exception { when( stepMenuExtension.getTransGraph() ).thenReturn( transGraph ); when( transGraph.getTransMeta() ).thenReturn( transMeta ); when( transGraph.getCurrentStep() ).thenReturn( stepMeta ); when( stepMenuExtension.getMenu() ).thenReturn( menupopup ); when( stepMeta.getName() ).thenReturn( STEP_NAME ); when( dataServiceMeta.isUserDefined() ).thenReturn( true ); when( metaStoreUtil.getDataServiceByStepName( transMeta, stepMeta.getName() ) ).thenReturn( dataServiceMeta ); when( menupopup.getElementById( anyString() ) ).thenReturn( component ); dataServiceStepMenuExtension.callExtensionPoint( log, stepMenuExtension ); verify( stepMenuExtension, times( 2 ) ).getTransGraph(); verify( transGraph ).getTransMeta(); verify( transGraph ).getCurrentStep(); verify( stepMenuExtension ).getMenu(); verify( metaStoreUtil ).getDataServiceByStepName( transMeta, stepMeta.getName() ); verify( menupopup, times( 4 ) ).getElementById( anyString() ); verify( component, times( 3 ) ).setDisabled( false ); verify( component, times( 1 ) ).setDisabled( true ); }
@Test public void testCallExtensionPointWithTransient() throws Exception { when( stepMenuExtension.getTransGraph() ).thenReturn( transGraph ); when( transGraph.getTransMeta() ).thenReturn( transMeta ); when( transGraph.getCurrentStep() ).thenReturn( stepMeta ); when( stepMenuExtension.getMenu() ).thenReturn( menupopup ); when( stepMeta.getName() ).thenReturn( STEP_NAME ); when( dataServiceMeta.isUserDefined() ).thenReturn( false ); when( metaStoreUtil.getDataServiceByStepName( transMeta, stepMeta.getName() ) ).thenReturn( dataServiceMeta ); when( menupopup.getElementById( anyString() ) ).thenReturn( component ); dataServiceStepMenuExtension.callExtensionPoint( log, stepMenuExtension ); verify( stepMenuExtension, times( 2 ) ).getTransGraph(); verify( transGraph ).getTransMeta(); verify( transGraph ).getCurrentStep(); verify( stepMenuExtension ).getMenu(); verify( metaStoreUtil ).getDataServiceByStepName( transMeta, stepMeta.getName() ); verify( menupopup, times( 4 ) ).getElementById( anyString() ); verify( component, times( 1 ) ).setDisabled( false ); verify( component, times( 3 ) ).setDisabled( true ); }