Skip to content
Snippets Groups Projects
Commit 98038167 authored by Zhibin Mai's avatar Zhibin Mai
Browse files

Fix unit test

parent 98f5af45
No related branches found
No related tags found
1 merge request!496Provide an endpoint to create aliases for all existing indices that do not have aliases
Pipeline #171486 failed
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment