In integration testing, I use a real remote server to consume REST APIs. What's the simplest way to provide those responses within a unit test w/o depending on external entity.
One possible approach is to build
public class TestHttpResponse implements org.apache.http.client.methods.CloseableHttpResponse
override
@Override
public StatusLine getStatusLine() {
return new StatusLine() {
@Override
public ProtocolVersion getProtocolVersion() {
return null;
}
@Override
public int getStatusCode() {
return statusCode;
}
@Override
public String getReasonPhrase() {
return reasonPhrase;
}
};
}
...
Is there a simpler and better way for mocking REST API response payloads?