Skip to content

Commit

Permalink
Added setDefaultMediaType for create_index and create_index_with_IOEx…
Browse files Browse the repository at this point in the history
…ception

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
  • Loading branch information
MitchellGale committed Jul 25, 2023
1 parent 843cf0a commit 7696251
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.opensearch.core.xcontent.MediaTypeParserRegistry.setDefaultMediaType;
import static org.opensearch.sql.opensearch.client.OpenSearchClient.META_CLUSTER_NAME;
import static org.opensearch.sql.opensearch.data.type.OpenSearchDataType.MappingType;

Expand Down Expand Up @@ -129,6 +130,7 @@ void is_index_exist_with_exception() throws IOException {
@Test
void create_index() throws IOException {
String indexName = "test";
setDefaultMediaType(XContentType.JSON);
Map<String, Object> mappings = ImmutableMap.of(
"properties",
ImmutableMap.of("name", "text"));
Expand All @@ -142,7 +144,7 @@ void create_index() throws IOException {
@Test
void create_index_with_IOException() throws IOException {
when(restClient.indices().create(any(), any())).thenThrow(IOException.class);

setDefaultMediaType(XContentType.JSON);
assertThrows(IllegalStateException.class,
() -> client.createIndex("test", ImmutableMap.of()));
}
Expand Down

0 comments on commit 7696251

Please sign in to comment.