RussellSpitzer commented on code in PR #16024:
URL: https://github.com/apache/iceberg/pull/16024#discussion_r3164264428
##########
core/src/test/java/org/apache/iceberg/rest/responses/TestFetchPlanningResultResponseParser.java:
##########
@@ -330,4 +330,45 @@ public void roundTripSerdeWithCredentials() {
assertThat(FetchPlanningResultResponseParser.toJson(copyResponse, true))
.isEqualTo(expectedJson);
}
+
+ @Test
+ public void roundTripSerdeWithFailedStatusAndErrorResponse() {
+ ErrorResponse errorResponse =
+ ErrorResponse.builder()
+ .withMessage("Scan planning failed: table too large to plan")
+ .withType("IllegalStateException")
+ .responseCode(500)
+ .build();
+
+ FetchPlanningResultResponse response =
+ FetchPlanningResultResponse.builder()
+ .withPlanStatus(PlanStatus.FAILED)
+ .withErrorResponse(errorResponse)
+ .build();
+
+ String expectedJson =
+ "{\"status\":\"failed\","
+ + "\"error\":{\"message\":\"Scan planning failed: table too large
to plan\","
+ + "\"type\":\"IllegalStateException\",\"code\":500}}";
+ String json = FetchPlanningResultResponseParser.toJson(response);
+ assertThat(json).isEqualTo(expectedJson);
+
+ FetchPlanningResultResponse fromResponse =
+ FetchPlanningResultResponseParser.fromJson(json,
PARTITION_SPECS_BY_ID, false);
+ assertThat(fromResponse.planStatus()).isEqualTo(PlanStatus.FAILED);
+ assertThat(fromResponse.errorResponse()).isNotNull();
+ assertThat(fromResponse.errorResponse().message())
+ .isEqualTo("Scan planning failed: table too large to plan");
+
assertThat(fromResponse.errorResponse().type()).isEqualTo("IllegalStateException");
+ assertThat(fromResponse.errorResponse().code()).isEqualTo(500);
+ }
+
+ @Test
+ public void parseFailedStatusWithoutErrorObject() {
Review Comment:
It may make sense to note this is not spec compliant and since we are going
to cover it, we should probably also add a test for Error being a primitive and
not an object.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]