Skip to content

Commit 8029732

Browse files
committed
test(gax-httpjson): add edge case tests for HttpJsonErrorParser
1 parent 50cfee9 commit 8029732

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonErrorParserTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,18 @@ void parseErrorDetails_noDetails() {
107107
String payload = "{\"error\": {}}";
108108
assertThat(HttpJsonErrorParser.parseErrorDetails(payload).getErrorInfo()).isNull();
109109
}
110+
111+
@Test
112+
void parseErrorDetails_garbageInError() {
113+
String payload = "{\"error\": \"not-an-object\"}";
114+
Assertions.assertThrows(
115+
RuntimeException.class, () -> HttpJsonErrorParser.parseErrorDetails(payload));
116+
}
117+
118+
@Test
119+
void parseErrorDetails_arrayInError() {
120+
String payload = "{\"error\": []}";
121+
Assertions.assertThrows(
122+
RuntimeException.class, () -> HttpJsonErrorParser.parseErrorDetails(payload));
123+
}
110124
}

0 commit comments

Comments
 (0)