接口的使用
cn.taketoday.test.web.client.RequestMatcher
使用RequestMatcher的程序包
程序包
说明
Web client test utilities.
Contains client-side REST testing support.
Contains built-in
RequestMatcher
implementations.-
cn.taketoday.framework.test.web.client中RequestMatcher的使用
修饰符和类型方法说明RootUriRequestExpectationManager.expectRequest(ExpectedCount count, RequestMatcher requestMatcher) -
cn.taketoday.test.web.client中RequestMatcher的使用
修饰符和类型接口说明interfaceAn extension ofResponseActionsthat also implementsRequestMatcherandResponseCreator修饰符和类型类说明classDefault implementation ofRequestExpectationthat simply delegates to the request matchers and the response creator it contains.类型参数类型为RequestMatcher的cn.taketoday.test.web.client中的字段返回变量类型为RequestMatcher的类型的cn.taketoday.test.web.client中的方法修饰符和类型方法说明DefaultRequestExpectation.andExpect(RequestMatcher requestMatcher) ResponseActions.andExpect(RequestMatcher requestMatcher) Add a request expectation.MockRestServiceServer.expect(ExpectedCount count, RequestMatcher matcher) An alternative toMockRestServiceServer.expect(RequestMatcher)that also indicates how many times the request is expected to be executed.MockRestServiceServer.expect(RequestMatcher matcher) Set up an expectation for a single HTTP request.AbstractRequestExpectationManager.expectRequest(ExpectedCount count, RequestMatcher matcher) RequestExpectationManager.expectRequest(ExpectedCount count, RequestMatcher requestMatcher) Set up a new request expectation.参数类型为RequestMatcher的cn.taketoday.test.web.client中的构造器限定符构造器说明DefaultRequestExpectation(ExpectedCount expectedCount, RequestMatcher requestMatcher) Create a new request expectation that should be called a number of times as indicated byRequestCount. -
cn.taketoday.test.web.client.match中RequestMatcher的使用
修饰符和类型接口说明private static interfaceFunctional interface for XPathRequestMatcherimplementations.修饰符和类型类说明private static classAbstract base class for XMLRequestMatcher's.private static classAbstract base class forJsonPath-basedRequestMatchers.修饰符和类型方法说明static RequestMatcherMockRestRequestMatchers.anything()Match to any request.XpathRequestMatchers.booleanValue(Boolean value) Apply the XPath and assert the boolean value found.ContentRequestMatchers.bytes(byte[] expectedContent) Compare the body of the request to the given byte array.ContentRequestMatchers.contentType(cn.taketoday.http.MediaType expectedContentType) Assert the request content type as aMediaType.ContentRequestMatchers.contentType(String expectedContentType) Assert the request content type as a String.ContentRequestMatchers.contentTypeCompatibleWith(cn.taketoday.http.MediaType contentType) Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType).ContentRequestMatchers.contentTypeCompatibleWith(String contentType) Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType).JsonPathRequestMatchers.doesNotExist()Evaluate the JSON path expression against the request content and assert that a value does not exist at the given path.XpathRequestMatchers.doesNotExist()Assert that content does not exist at the given XPath.JsonPathRequestMatchers.doesNotHaveJsonPath()Evaluate the JSON path expression against the suppliedcontentand assert that a value, includingnullvalues, does not exist at the given path.JsonPathRequestMatchers.exists()Evaluate the JSON path expression against the request content and assert that a non-null value exists at the given path.XpathRequestMatchers.exists()Assert that content exists at the given XPath.Parse the body as form data and compare to the givenMultiValueMap.private RequestMatcherContentRequestMatchers.formData(cn.taketoday.util.MultiValueMap<String, String> expectedMap, boolean containsExactly) ContentRequestMatchers.formDataContains(Map<String, String> expected) Variant ofContentRequestMatchers.formData(MultiValueMap)that matches the given subset of expected form parameters.JsonPathRequestMatchers.hasJsonPath()Evaluate the JSON path expression against the response content and assert that a value, possiblynull, exists.static RequestMatcherAssert request header values.static RequestMatcherAssert request header values with the given Hamcrest matcher(s).static RequestMatcherMockRestRequestMatchers.headerDoesNotExist(String name) Assert that the given request header does not exist.JsonPathRequestMatchers.isArray()Evaluate the JSON path expression against the request content and assert that the result is an array.JsonPathRequestMatchers.isBoolean()Evaluate the JSON path expression against the request content and assert that the result is aBoolean.JsonPathRequestMatchers.isEmpty()Evaluate the JSON path expression against the request content and assert that an empty value exists at the given path.JsonPathRequestMatchers.isMap()Evaluate the JSON path expression against the request content and assert that the result is aMap.JsonPathRequestMatchers.isNotEmpty()Evaluate the JSON path expression against the request content and assert that a non-empty value exists at the given path.JsonPathRequestMatchers.isNumber()Evaluate the JSON path expression against the request content and assert that the result is aNumber.JsonPathRequestMatchers.isString()Evaluate the JSON path expression against the request content and assert that the result is aString.Parse the expected and actual strings as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting with a lenient checking (extensible, and non-strict array ordering).Parse the request body and the given string as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting.static <T> RequestMatcherAccess to request body matchers using a JsonPath expression to inspect a specific subset of the body and a Hamcrest match for asserting the value found at the JSON path.static RequestMatcherMockRestRequestMatchers.method(cn.taketoday.http.HttpMethod method) Assert theHttpMethodof the request.ContentRequestMatchers.multipartData(cn.taketoday.util.MultiValueMap<String, ?> expectedMap) Parse the body as multipart data and assert it contains exactly the values from the givenMultiValueMap.private RequestMatcherContentRequestMatchers.multipartData(cn.taketoday.util.MultiValueMap<String, ?> expectedMap, boolean containsExactly) ContentRequestMatchers.multipartDataContains(Map<String, ?> expectedMap) Variant ofContentRequestMatchers.multipartData(MultiValueMap)that does the same but only for a subset of the actual values.Parse the request content asNodeand apply the givenMatcher.Apply the XPath and assert it with the givenMatcher<Node>.XpathRequestMatchers.nodeCount(int expectedCount) Apply the XPath and assert the number of nodes found.Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>.Apply the XPath and assert the number value found.Apply the XPath and assert the number found with the given matcher.static RequestMatcherMockRestRequestMatchers.queryParam(String name, String... expectedValues) Assert request query parameter values.static RequestMatcherMockRestRequestMatchers.queryParam(String name, org.hamcrest.Matcher<? super String>... matchers) Assert request query parameter values with the given Hamcrest matcher(s).static RequestMatcherAssert the request URI matches the given string.static RequestMatcherExpect a request to the given URI.static RequestMatcherAssert the request URI string with the given Hamcrest matcher.static RequestMatcherMockRestRequestMatchers.requestToUriTemplate(String expectedUri, Object... uriVars) Variant ofMockRestRequestMatchers.requestTo(URI)that prepares the URI from a URI template plus optional variables viaUriComponentsBuilderincluding encoding.Parse the request content asDOMSourceand apply the givenMatcher.Get the body of the request as a UTF-8 string and compare it to the given String.Get the body of the request as a UTF-8 string and apply the givenMatcher.Apply the XPath and assert the String content found.Apply the XPath and assert the String content found with the given matcher.Evaluate the JSON path expression against the request content and assert that the result is equal to the supplied value.<T> RequestMatcherJsonPathRequestMatchers.value(org.hamcrest.Matcher<? super T> matcher) Evaluate the JSON path expression against the request content and assert the resulting value with the given HamcrestMatcher.<T> RequestMatcherAn overloaded variant ofJsonPathRequestMatchers.value(Matcher)that also accepts a target type for the resulting value that the matcher can work reliably against.Parse the request body and the given String as XML and assert that the two are "similar" - i.e. they contain the same elements and attributes regardless of order.