diff --git a/dialogue-serde/src/test/java/com/palantir/conjure/java/dialogue/serde/ConjureBodySerDeTest.java b/dialogue-serde/src/test/java/com/palantir/conjure/java/dialogue/serde/ConjureBodySerDeTest.java index da7ea260c..5472ac745 100644 --- a/dialogue-serde/src/test/java/com/palantir/conjure/java/dialogue/serde/ConjureBodySerDeTest.java +++ b/dialogue-serde/src/test/java/com/palantir/conjure/java/dialogue/serde/ConjureBodySerDeTest.java @@ -22,11 +22,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; import com.palantir.conjure.java.api.errors.ErrorType; import com.palantir.conjure.java.api.errors.RemoteException; import com.palantir.conjure.java.api.errors.SerializableError; import com.palantir.conjure.java.api.errors.ServiceException; +import com.palantir.conjure.java.serialization.ObjectMappers; import com.palantir.dialogue.BinaryRequestBody; import com.palantir.dialogue.BodySerDe; import com.palantir.dialogue.RequestBody; @@ -47,6 +50,7 @@ @ExtendWith(MockitoExtension.class) public class ConjureBodySerDeTest { + private static final ObjectMapper SERVER_MAPPER = ObjectMappers.newServerObjectMapper(); private static final TypeMarker TYPE = new TypeMarker() {}; private static final TypeMarker> OPTIONAL_TYPE = new TypeMarker>() {}; @@ -137,14 +141,12 @@ public void testRequestUnknownContentType() throws IOException { } @Test - public void testErrorsDecoded() { - TestResponse response = new TestResponse().code(400); - + public void testErrorsDecoded() throws JsonProcessingException { ServiceException serviceException = new ServiceException(ErrorType.INVALID_ARGUMENT); SerializableError serialized = SerializableError.forException(serviceException); - errorDecoder = mock(ErrorDecoder.class); - when(errorDecoder.isError(response)).thenReturn(true); - when(errorDecoder.decode(response)).thenReturn(new RemoteException(serialized, 400)); + TestResponse response = TestResponse.withBody(SERVER_MAPPER.writeValueAsString(serialized)) + .code(400) + .contentType("application/json"); BodySerDe serializers = conjureBodySerDe("text/plain");