1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
22
22
import org .springframework .http .client .ClientHttpResponse ;
23
23
24
24
/**
25
- * Abstraction for creating HTTP request expectations, applying them to actual
26
- * requests (in strict or random order), and verifying whether expectations
27
- * have been met.
25
+ * Encapsulates the behavior required to implement {@link MockRestServiceServer}
26
+ * including its public API (create expectations + verify/reset) along with an
27
+ * extra method for verifying actual requests.
28
+ *
29
+ * <p>This contract is not used directly in applications but a custom
30
+ * implementation can be
31
+ * {@link org.springframework.test.web.client.MockRestServiceServer.MockRestServiceServerBuilder#build(RequestExpectationManager)
32
+ * plugged} in through the {@code MockRestServiceServer} builder.
28
33
*
29
34
* @author Rossen Stoyanchev
30
35
* @since 4.3
@@ -34,30 +39,41 @@ public interface RequestExpectationManager {
34
39
/**
35
40
* Set up a new request expectation. The returned {@link ResponseActions} is
36
41
* used to add more expectations and define a response.
42
+ * <p>This is a delegate for
43
+ * {@link MockRestServiceServer#expect(ExpectedCount, RequestMatcher)}.
44
+ *
37
45
* @param requestMatcher a request expectation
38
46
* @return for setting up further expectations and define a response
47
+ * @see MockRestServiceServer#expect(RequestMatcher)
48
+ * @see MockRestServiceServer#expect(ExpectedCount, RequestMatcher)
39
49
*/
40
50
ResponseActions expectRequest (ExpectedCount count , RequestMatcher requestMatcher );
41
51
42
- /**
43
- * Validate the given actual request against the declared expectations.
44
- * Is successful return the mock response to use or raise an error.
45
- * @param request the request
46
- * @return the response to return if the request was validated.
47
- * @throws AssertionError when some expectations were not met
48
- * @throws IOException in case of any validation errors
49
- */
50
- ClientHttpResponse validateRequest (ClientHttpRequest request ) throws IOException ;
51
-
52
52
/**
53
53
* Verify that all expectations have been met.
54
+ * <p>This is a delegate for {@link MockRestServiceServer#verify()}.
54
55
* @throws AssertionError when some expectations were not met
56
+ * @see MockRestServiceServer#verify()
55
57
*/
56
58
void verify ();
57
59
58
60
/**
59
61
* Reset the internal state removing all expectations and recorded requests.
62
+ * <p>This is a delegate for {@link MockRestServiceServer#reset()}.
63
+ * @see MockRestServiceServer#reset()
60
64
*/
61
65
void reset ();
62
66
67
+
68
+ /**
69
+ * Validate the given actual request against the declared expectations.
70
+ * Is successful return the mock response to use or raise an error.
71
+ * <p>This is used in {@link MockRestServiceServer} against actual requests.
72
+ * @param request the request
73
+ * @return the response to return if the request was validated.
74
+ * @throws AssertionError when some expectations were not met
75
+ * @throws IOException in case of any validation errors
76
+ */
77
+ ClientHttpResponse validateRequest (ClientHttpRequest request ) throws IOException ;
78
+
63
79
}
0 commit comments