NamedClusterConfigBuilder extends KettleGenericFileSystemConfigBuilder { public void snapshotNamedClusterToMetaStore( IMetaStore snapshotMetaStore ) throws MetaStoreException { IMetaStore metaStore = metastoreLocator.getMetastore(); List<NamedCluster> ncList = namedClusterService.list( metaStore ); if ( ncList != null ) { for ( NamedCluster nc : ncList ) { namedClusterService.create( nc, snapshotMetaStore ); } } } NamedClusterConfigBuilder();  NamedClusterConfigBuilder( MetastoreLocatorOsgi metastoreLocator, NamedClusterService namedClusterService ); static NamedClusterConfigBuilder getInstance(); static FileSystemConfigBuilder getInstance( MetastoreLocatorOsgi metastoreLocator,  NamedClusterService namedClusterService ); void snapshotNamedClusterToMetaStore( IMetaStore snapshotMetaStore ); void setEmbeddedMetastoreKey( final FileSystemOptions opts, final String embeddedMetaStoreKey ); String getEmbeddedMetastoreKey( final FileSystemOptions opts );  }
@Test public void testSnapshotNamedClusterToMetaStore() throws MetaStoreException { when( namedClusterService.list( eq( metastore ) ) ).thenReturn( Arrays.asList( namedCluster ) ); NamedClusterConfigBuilder builder = new NamedClusterConfigBuilder( metastoreLocator, namedClusterService ); builder.snapshotNamedClusterToMetaStore( metastore ); verify( namedClusterService ).create( eq( namedCluster ), eq( metastore ) ); }
@Test public void testSnapshotNamedClusterToMetaStore_MetastoreDoesNotHaveNC() throws MetaStoreException { when( namedClusterService.list( eq( metastore ) ) ).thenReturn( null ); NamedClusterConfigBuilder builder = new NamedClusterConfigBuilder( metastoreLocator, namedClusterService ); builder.snapshotNamedClusterToMetaStore( metastore ); verify( namedClusterService, never() ).create( eq( namedCluster ), eq( metastore ) ); }