public void clear() {
    NamedClusterServiceOsgi ncso = meta.getNamedClusterServiceOsgi();
    if ( ncso != null ) {  //Don't kill the embedded if we don't have the service to rebuild
      addedAllClusters = false;
      addedAnyClusters = false;
      // The embeddedMetaStoreFactory may be null if creating a brand new job and attempting to run before it ever
      // saved.
      if ( embeddedMetaStoreFactory != null ) {
        try {
          List<NamedClusterOsgi> list = embeddedMetaStoreFactory.getElements();
          for ( NamedClusterOsgi nc : list ) {
            namedClusterPool.put( nc.getName(), nc );
            embeddedMetaStoreFactory.deleteElement( nc.getName() );
          }
        } catch ( MetaStoreException e ) {
          logMetaStoreException( e );
        }
      }
    }
  }
@Test
  public void testClear() throws Exception {
    when( mockMetaStoreFactory.getElements() )
      .thenReturn( Arrays.asList( mockNamedCluster1, mockNamedCluster2 ) );

    namedClusterEmbedManager.clear( );
    verify( mockMetaStoreFactory ).deleteElement( CLUSTER1_NAME );
    verify( mockMetaStoreFactory ).deleteElement( CLUSTER2_NAME );
  }