-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: panguixin <panguixin@bytedance.com>
- Loading branch information
1 parent
e8fa1cd
commit 634d577
Showing
4 changed files
with
44 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...rch/src/test/java/org/opensearch/sql/opensearch/data/utils/OpenSearchJsonContentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.opensearch.data.utils; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import java.io.IOException; | ||
import org.junit.jupiter.api.Test; | ||
import org.opensearch.OpenSearchParseException; | ||
|
||
public class OpenSearchJsonContentTest { | ||
@Test | ||
public void testGetValueWithIOException() throws IOException { | ||
JsonNode jsonNode = mock(JsonNode.class); | ||
JsonParser jsonParser = mock(JsonParser.class); | ||
when(jsonNode.traverse()).thenReturn(jsonParser); | ||
when(jsonParser.nextToken()).thenThrow(new IOException()); | ||
OpenSearchJsonContent content = new OpenSearchJsonContent(jsonNode); | ||
OpenSearchParseException exception = | ||
assertThrows(OpenSearchParseException.class, content::geoValue); | ||
assertTrue(exception.getMessage().contains("error parsing geo point")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters