diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndicesServiceTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndicesServiceTest.java index 7f22b619a9364b308791473adbae5324a0687d9a..7bc3fe17d8a060337c7b624fe7d7c76036ff3d7f 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndicesServiceTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/IndicesServiceTest.java @@ -77,6 +77,8 @@ public class IndicesServiceTest { private Response response; @Mock private HttpEntity httpEntity; + @Mock + private IndexAliasService indexAliasService; @InjectMocks private IndicesServiceImpl sut; @@ -94,22 +96,19 @@ public class IndicesServiceTest { @Test public void create_elasticIndex() throws Exception { - String kind = "common:welldb:wellbore:1.2.0"; String index = "common-welldb-wellbore-1.2.0"; CreateIndexResponse indexResponse = new CreateIndexResponse(true, true, index); AcknowledgedResponse acknowledgedResponse = new AcknowledgedResponse(true); - when(elasticIndexNameResolver.getKindFromIndexName(any())).thenReturn(kind); when(elasticIndexNameResolver.getIndexNameFromKind(any())).thenReturn(index); - when(elasticIndexNameResolver.getIndexAliasFromKind(any())).thenReturn("a12345678"); - when(elasticIndexNameResolver.isIndexAliasSupported(any())).thenReturn(true); when(restHighLevelClient.indices()).thenReturn(indicesClient); when(indicesClient.create(any(CreateIndexRequest.class), any(RequestOptions.class))).thenReturn(indexResponse); when(indicesClient.updateAliases(any(IndicesAliasesRequest.class), any(RequestOptions.class))).thenReturn(acknowledgedResponse); + boolean response = this.sut.createIndex(restHighLevelClient, index, null, "anytype", new HashMap<>()); assertTrue(response); when(this.indicesExistCache.get(index)).thenReturn(true); - verify(this.indicesClient, times(2)).updateAliases(any(IndicesAliasesRequest.class), any(RequestOptions.class)); + verify(this.indexAliasService, times(1)).createIndexAlias(any(), any()); } @Test