Skip to content

Commit

Permalink
test: create failing test for GetAliasRequest with not existing index (
Browse files Browse the repository at this point in the history
…opensearch-project#301)

Signed-off-by: Dominik Szczepanczyk <[email protected]>
  • Loading branch information
szczepanczykd committed Mar 7, 2023
1 parent 9b9ec00 commit 89acf69
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.opensearch.client.opensearch.OpenSearchAsyncClient;
import org.opensearch.client.opensearch._types.OpenSearchException;
import org.opensearch.client.opensearch.indices.CreateIndexResponse;
import org.opensearch.client.opensearch.indices.GetAliasRequest;
import org.opensearch.client.opensearch.indices.GetAliasResponse;
import org.opensearch.client.opensearch.indices.GetIndexRequest;
import org.opensearch.client.opensearch.indices.GetIndexResponse;
import org.opensearch.client.opensearch.indices.GetIndicesSettingsRequest;
Expand Down Expand Up @@ -106,4 +108,19 @@ public void testGetSettingsNonExistentIndex() throws IOException {
"no such index [index_that_doesnt_exist]");
}
}

public void testGetNotExistingIndexAlias() throws Exception {
String notExistingIndexAlias = "alias_not_exists";
GetAliasRequest aliasRequest = new GetAliasRequest.Builder().name(notExistingIndexAlias).build();
try {
GetAliasResponse response = javaClient().indices().getAlias(aliasRequest);
fail();
} catch (OpenSearchException ex) {
assertNotNull(ex);
assertEquals(ex.status(), 404);
assertEquals(ex.getMessage(),
"Request failed: [string_error] " +
"alias [alias_not_exists] missing");
}
}
}

0 comments on commit 89acf69

Please sign in to comment.