Skip to content

Commit

Permalink
Fix create_index/create_index_with_IOException issue caused by OpenSe…
Browse files Browse the repository at this point in the history
…arch PR change (#1899)

* Added setDefaultMediaType for create_index and create_index_with_IOException


Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale authored Jul 26, 2023
1 parent af12c02 commit 7b932a7
Showing 1 changed file with 7 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 All @@ -34,6 +35,7 @@
import lombok.SneakyThrows;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.lucene.search.TotalHits;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
Expand Down Expand Up @@ -101,6 +103,11 @@ void setUp() {
client = new OpenSearchRestClient(restClient);
}

@BeforeAll
static void setUpJSON() {
setDefaultMediaType(XContentType.JSON);
}

@Test
void is_index_exist() throws IOException {
when(restClient.indices()
Expand Down Expand Up @@ -142,7 +149,6 @@ void create_index() throws IOException {
@Test
void create_index_with_IOException() throws IOException {
when(restClient.indices().create(any(), any())).thenThrow(IOException.class);

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

0 comments on commit 7b932a7

Please sign in to comment.