From 9803816742a6fc6071222a7c3ddc68f4dd021b7d Mon Sep 17 00:00:00 2001
From: ZMai <zmai@slb.com>
Date: Wed, 22 Feb 2023 06:47:09 -0600
Subject: [PATCH] Fix unit test

---
 .../osdu/indexer/service/IndicesServiceTest.java         | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

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 7f22b619a..7bc3fe17d 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
-- 
GitLab