Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Add more UT
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-chen committed Jan 22, 2021
1 parent 5b1b680 commit f0297e3
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonParser;
import java.util.Arrays;
import org.elasticsearch.ElasticsearchException;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -154,6 +155,25 @@ void format_server_error_response() {
);
}

@Test
void format_server_error_response_due_to_elasticsearch() {
assertJsonEquals(
"{\"error\":"
+ "{\""
+ "type\":\"ElasticsearchException\","
+ "\"reason\":\"Error occurred in Elasticsearch engine: all shards failed\","
+ "\"details\":\"ElasticsearchException[all shards failed]; "
+ "nested: IllegalStateException[Execution error];; "
+ "java.lang.IllegalStateException: Execution error\\n"
+ "For more details, please send request for Json format to see the raw response "
+ "from elasticsearch engine.\""
+ "},"
+ "\"status\":503}",
formatter.format(new ElasticsearchException("all shards failed",
new IllegalStateException("Execution error")))
);
}

private static void assertJsonEquals(String expected, String actual) {
assertEquals(
JsonParser.parseString(expected),
Expand Down

0 comments on commit f0297e3

Please sign in to comment.