@SuppressWarnings("deprecation") @Override public ClientHttpResponse validateRequest(ClientHttpRequest request) throws IOException { RequestExpectation expectation = null; synchronized (this.requests) { if (this.requests.isEmpty()) { afterExpectationsDeclared(); } try { // Try this first for backwards compatibility ClientHttpResponse response = validateRequestInternal(request); if (response != null) { return response; } else { expectation = matchRequest(request); } } finally { this.requests.add(request); } } return expectation.createResponse(request); }
@Override public ClientHttpResponse validateRequestInternal(ClientHttpRequest request) throws IOException { RequestExpectation expectation = this.repeatExpectations.findExpectation(request); if (expectation == null) { if (!this.expectationIterator.hasNext()) { throw createUnexpectedRequestError(request); } expectation = this.expectationIterator.next(); expectation.match(request); } ClientHttpResponse response = expectation.createResponse(request); this.repeatExpectations.update(expectation); return response; }
@SuppressWarnings("deprecation") @Override public ClientHttpResponse validateRequest(ClientHttpRequest request) throws IOException { RequestExpectation expectation = null; synchronized (this.requests) { if (this.requests.isEmpty()) { afterExpectationsDeclared(); } try { // Try this first for backwards compatibility ClientHttpResponse response = validateRequestInternal(request); if (response != null) { return response; } else { expectation = matchRequest(request); } } finally { this.requests.add(request); } } return expectation.createResponse(request); }
@Override public ClientHttpResponse validateRequestInternal(ClientHttpRequest request) throws IOException { RequestExpectation expectation = this.remainingExpectations.findExpectation(request); if (expectation != null) { ClientHttpResponse response = expectation.createResponse(request); this.remainingExpectations.update(expectation); return response; } throw createUnexpectedRequestError(request); }
ClientHttpResponse response = expectation.createResponse(request); this.remainingExpectations.update(expectation); return response;