|
28 | 28 | import com.google.common.util.concurrent.UncheckedExecutionException; |
29 | 29 | import com.palantir.conjure.java.api.errors.RemoteException; |
30 | 30 | import com.palantir.conjure.java.api.errors.SerializableError; |
| 31 | +import com.palantir.conjure.java.api.errors.SerializableErrorProvider; |
31 | 32 | import com.palantir.conjure.java.client.jaxrs.JaxRsClient; |
32 | 33 | import com.palantir.conjure.java.lib.SafeLong; |
33 | 34 | import com.palantir.conjure.java.okhttp.HostMetricsRegistry; |
34 | 35 | import com.palantir.conjure.java.serialization.ObjectMappers; |
35 | 36 | import com.palantir.conjure.java.undertow.runtime.ConjureHandler; |
36 | 37 | import com.palantir.dialogue.BinaryRequestBody; |
37 | 38 | import com.palantir.dialogue.clients.DialogueClients; |
| 39 | +import com.palantir.logsafe.exceptions.SafeUncheckedIoException; |
38 | 40 | import com.palantir.ri.ResourceIdentifier; |
39 | 41 | import com.palantir.tokens.auth.AuthHeader; |
40 | 42 | import dialogue.com.palantir.product.EteBinaryServiceBlocking; |
@@ -555,12 +557,24 @@ public void testListOfNull() { |
555 | 557 |
|
556 | 558 | @Test |
557 | 559 | public void testErrorParametersSerializedAsJson() { |
| 560 | + ObjectMapper objectMapper = ObjectMappers.newClientObjectMapper(); |
558 | 561 | try { |
559 | 562 | exceptionThrowingClient.jsonErrorsHeader(AuthHeader.valueOf("authHeader"), "JSON"); |
560 | 563 | } catch (RemoteException e) { |
561 | 564 | assertThat(e.getError().parameters()) |
562 | 565 | .containsExactlyInAnyOrderEntriesOf( |
563 | 566 | Map.of("serviceName", "my-service-string", "serviceDef", SimpleEnum.VALUE.toString())); |
| 567 | + // Assert that error parameters can be re-serialized as JSON. |
| 568 | + assertThat(e).isInstanceOfSatisfying(SerializableErrorProvider.class, errorProvider -> { |
| 569 | + try { |
| 570 | + String serialized = objectMapper.writeValueAsString( |
| 571 | + errorProvider.error().parameterMap()); |
| 572 | + assertThat(serialized) |
| 573 | + .isEqualTo("{\"serviceName\":\"my-service-string\",\"serviceDef\":\"VALUE\"}"); |
| 574 | + } catch (IOException exception) { |
| 575 | + throw new SafeUncheckedIoException("Failed to serialize parameters", exception); |
| 576 | + } |
| 577 | + }); |
564 | 578 | } |
565 | 579 |
|
566 | 580 | try { |
|
0 commit comments