@Override public ResponseActions expectRequest(ExpectedCount count, RequestMatcher matcher) { Assert.state(this.requests.isEmpty(), "Cannot add more expectations after actual requests are made"); RequestExpectation expectation = new DefaultRequestExpectation(count, matcher); this.expectations.add(expectation); return expectation; }
@Test public void match() throws Exception { RequestExpectation expectation = new DefaultRequestExpectation(once(), requestTo("/foo")); expectation.match(createRequest(GET, "/foo")); }
@Test public void matchWithFailedExpectation() throws Exception { RequestExpectation expectation = new DefaultRequestExpectation(once(), requestTo("/foo")); expectation.andExpect(method(POST)); this.thrown.expectMessage("Unexpected HttpMethod expected:<POST> but was:<GET>"); expectation.match(createRequest(GET, "/foo")); }
@Test public void hasRemainingCount() { RequestExpectation expectation = new DefaultRequestExpectation(twice(), requestTo("/foo")); expectation.andRespond(withSuccess()); expectation.incrementAndValidate(); assertTrue(expectation.hasRemainingCount()); expectation.incrementAndValidate(); assertFalse(expectation.hasRemainingCount()); }
@Test public void isSatisfied() { RequestExpectation expectation = new DefaultRequestExpectation(twice(), requestTo("/foo")); expectation.andRespond(withSuccess()); expectation.incrementAndValidate(); assertFalse(expectation.isSatisfied()); expectation.incrementAndValidate(); assertTrue(expectation.isSatisfied()); }
@Override public ResponseActions expectRequest(ExpectedCount count, RequestMatcher matcher) { Assert.state(this.requests.isEmpty(), "Cannot add more expectations after actual requests are made"); RequestExpectation expectation = new DefaultRequestExpectation(count, matcher); this.expectations.add(expectation); return expectation; }
@Override public ResponseActions expectRequest(ExpectedCount count, RequestMatcher matcher) { Assert.state(getRequests().isEmpty(), "Cannot add more expectations after actual requests are made"); RequestExpectation expectation = new DefaultRequestExpectation(count, matcher); getExpectations().add(expectation); return expectation; }