use of com.palantir.conjure.java.api.errors.RemoteException in project dialogue by palantir.
the class ConjureBodySerDeTest method testEmptyResponse_failure.
@Test
public void testEmptyResponse_failure() {
TestResponse response = new TestResponse().code(400);
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));
BodySerDe serializers = conjureBodySerDe("application/json");
assertThatExceptionOfType(RemoteException.class).isThrownBy(() -> serializers.emptyBodyDeserializer().deserialize(response));
}
use of com.palantir.conjure.java.api.errors.RemoteException in project dialogue by palantir.
the class ConjureBodySerDeTest method testErrorsDecoded.
@Test
public void testErrorsDecoded() {
TestResponse response = new TestResponse().code(400);
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));
BodySerDe serializers = conjureBodySerDe("text/plain");
assertThatExceptionOfType(RemoteException.class).isThrownBy(() -> serializers.deserializer(TYPE).deserialize(response));
assertThat(response.isClosed()).describedAs("response should be closed").isTrue();
assertThat(response.body().isClosed()).describedAs("inputstream should be closed").isTrue();
}
Aggregations