Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change #1899

Merged
merged 9 commits into from
Jul 26, 2023
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
Loading