HadoopClusterDelegateImpl extends SpoonDelegate { public void delNamedCluster( IMetaStore metaStore, NamedCluster namedCluster ) { if ( metaStore == null ) { metaStore = spoon.getMetaStore(); } deleteNamedCluster( metaStore, namedCluster ); spoon.refreshTree( STRING_NAMED_CLUSTERS ); spoon.setShellText(); } HadoopClusterDelegateImpl( Spoon spoon, NamedClusterService namedClusterService,
                                    RuntimeTestActionService runtimeTestActionService, RuntimeTester runtimeTester );  HadoopClusterDelegateImpl( Spoon spoon, NamedClusterService namedClusterService,
                                    RuntimeTestActionService runtimeTestActionService, RuntimeTester runtimeTester,
                                    CommonDialogFactory commonDialogFactory ); void dupeNamedCluster( IMetaStore metaStore, NamedCluster nc, Shell shell ); void delNamedCluster( IMetaStore metaStore, NamedCluster namedCluster ); String editNamedCluster( IMetaStore metaStore, NamedCluster namedCluster, Shell shell ); String newNamedCluster( VariableSpace variableSpace, IMetaStore metaStore, Shell shell ); static final String SPOON_DIALOG_ERROR_DELETING_NAMED_CLUSTER_TITLE; static final String SPOON_DIALOG_ERROR_DELETING_NAMED_CLUSTER_MESSAGE; static final String SPOON_VARIOUS_DUPE_NAME; static final String SPOON_DIALOG_ERROR_SAVING_NAMED_CLUSTER_TITLE; static final String SPOON_DIALOG_ERROR_SAVING_NAMED_CLUSTER_MESSAGE; static Class<?> PKG; static final String STRING_NAMED_CLUSTERS; static final String SPOON_DIALOG_ERROR_ADDING_NEW_CONFIGURATION_FOR_CLUSTER_TITLE; static final String SPOON_DIALOG_ERROR_ADDING_NEW_CONFIGURATION_FOR_CLUSTER_MESSAGE; static final String SPOON_DIALOG_ERROR_RENAMING_PREVIOUS_CLUSTER_CONFIG_TITLE; static final String SPOON_DIALOG_ERROR_RENAMING_PREVIOUS_CLUSTER_CONFIG_MESSAGE; }
@Test public void testDelNamedCluster() throws MetaStoreException { when( namedClusterService.read( namedClusterName, metaStore ) ).thenReturn( namedCluster ); hadoopClusterDelegate.delNamedCluster( metaStore, namedCluster ); verify( namedClusterService ).delete( namedClusterName, metaStore ); verify( spoon ).refreshTree( HadoopClusterDelegateImpl.STRING_NAMED_CLUSTERS ); verify( spoon ).setShellText(); }
@Test public void testDelNamedClusterNull() throws MetaStoreException { when( namedClusterService.read( namedClusterName, metaStore ) ).thenReturn( null ); hadoopClusterDelegate.delNamedCluster( metaStore, namedCluster ); verify( namedClusterService, never() ).delete( namedClusterName, metaStore ); verify( spoon ).refreshTree( HadoopClusterDelegateImpl.STRING_NAMED_CLUSTERS ); verify( spoon ).setShellText(); }
@Test public void testDelNamedClusterNullMetastore() throws MetaStoreException { DelegatingMetaStore metaStore2 = mock( DelegatingMetaStore.class ); when( spoon.getMetaStore() ).thenReturn( metaStore2 ); when( namedClusterService.read( namedClusterName, metaStore2 ) ).thenReturn( namedCluster ); hadoopClusterDelegate.delNamedCluster( null, namedCluster ); verify( namedClusterService ).delete( namedClusterName, metaStore2 ); verify( spoon ).refreshTree( HadoopClusterDelegateImpl.STRING_NAMED_CLUSTERS ); verify( spoon ).setShellText(); }
@Test public void testDelNamedClusterException() throws MetaStoreException { when( namedClusterService.read( namedClusterName, metaStore ) ).thenReturn( namedCluster ); MetaStoreException metaStoreException = new MetaStoreException(); doThrow( metaStoreException ).when( namedClusterService ).delete( namedClusterName, metaStore ); hadoopClusterDelegate.delNamedCluster( metaStore, namedCluster ); verify( commonDialogFactory ).createErrorDialog( shell, BaseMessages.getString( PKG, HadoopClusterDelegateImpl.SPOON_DIALOG_ERROR_DELETING_NAMED_CLUSTER_TITLE ), BaseMessages .getString( PKG, HadoopClusterDelegateImpl.SPOON_DIALOG_ERROR_DELETING_NAMED_CLUSTER_MESSAGE, namedClusterName ), metaStoreException ); verify( spoon ).refreshTree( HadoopClusterDelegateImpl.STRING_NAMED_CLUSTERS ); verify( spoon ).setShellText(); }