Search in sources :

Example 1 with MetadataDeleteIndexService

use of org.opensearch.cluster.metadata.MetadataDeleteIndexService in project OpenSearch by opensearch-project.

the class DeleteDataStreamRequestTests method getMetadataDeleteIndexService.

@SuppressWarnings("unchecked")
private static MetadataDeleteIndexService getMetadataDeleteIndexService() {
    MetadataDeleteIndexService s = mock(MetadataDeleteIndexService.class);
    when(s.deleteIndices(any(ClusterState.class), any(Set.class))).thenAnswer(mockInvocation -> {
        ClusterState currentState = (ClusterState) mockInvocation.getArguments()[0];
        Set<Index> indices = (Set<Index>) mockInvocation.getArguments()[1];
        final Metadata.Builder b = Metadata.builder(currentState.metadata());
        for (Index index : indices) {
            b.remove(index.getName());
        }
        return ClusterState.builder(currentState).metadata(b.build()).build();
    });
    return s;
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) Set(java.util.Set) MetadataDeleteIndexService(org.opensearch.cluster.metadata.MetadataDeleteIndexService) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) Index(org.opensearch.index.Index)

Aggregations

Set (java.util.Set)1 ClusterState (org.opensearch.cluster.ClusterState)1 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)1 Metadata (org.opensearch.cluster.metadata.Metadata)1 MetadataDeleteIndexService (org.opensearch.cluster.metadata.MetadataDeleteIndexService)1 Index (org.opensearch.index.Index)1