use of com.endava.cats.annotations.DryRun in project cats by Endava.
the class ServiceCaller method call.
/**
* When in dryRun mode ServiceCaller won't do any actual calls.
*
* @param data the current context data
* @return the result of service invocation
*/
@DryRun
public CatsResponse call(ServiceData data) {
LOGGER.note("Proxy configuration to be used: {}", authArguments.getProxy());
rateLimiter.acquire();
String processedPayload = this.replacePayloadWithRefData(data);
List<CatsRequest.Header> headers = this.buildHeaders(data);
CatsRequest catsRequest = new CatsRequest();
catsRequest.setHeaders(headers);
catsRequest.setPayload(processedPayload);
catsRequest.setHttpMethod(data.getHttpMethod().name());
try {
String url = this.getPathWithRefDataReplacedForHttpEntityRequests(data, apiArguments.getServer() + data.getRelativePath());
if (!HttpMethod.requiresBody(data.getHttpMethod())) {
url = this.getPathWithRefDataReplacedForNonHttpEntityRequests(data, apiArguments.getServer() + data.getRelativePath());
url = this.addUriParams(processedPayload, data, url);
}
catsRequest.setUrl(url);
LOGGER.note("Final list of request headers: {}", headers);
LOGGER.note("Final payload: {}", processedPayload);
CatsResponse response = this.callService(catsRequest, data.getFuzzedFields());
this.recordRequestAndResponse(catsRequest, response, data);
return response;
} catch (IOException e) {
this.recordRequestAndResponse(catsRequest, CatsResponse.empty(), data);
throw new CatsIOException(e);
}
}
Aggregations