final String resourceId = matchedLifecycle.getResourceId();
resourceStats.putIfAbsent(resourceId, new AtomicLong(0));
resourceStats.get(resourceId).incrementAndGet();
final StubResponse stubResponse = matchedLifecycle.getResponse(true);
if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
return new UnauthorizedStubResponse();
}
if (stubResponse.hasHeaderLocation()) {
return RedirectStubResponse.newRedirectStubResponse(stubResponse);
}
if (stubResponse.isRecordingRequired()) {
final String recordingSource = stubResponse.getBody();
try {
final StubbyResponse stubbyResponse = stubbyHttpTransport.fetchRecordableHTTPResponse(matchedLifecycle.getRequest(), recordingSource);
ReflectionUtils.injectObjectFields(stubResponse, YamlProperties.BODY, stubbyResponse.getContent());
} catch (Exception e) {
ANSITerminal.error(String.format("Could not record from %s: %s", recordingSource, e.toString()));