org.springframework.test.web.client.ResponseActions Java Examples

The following examples show how to use org.springframework.test.web.client.ResponseActions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WireMockRestServiceServer.java    From spring-cloud-contract with Apache License 2.0 6 votes vote down vote up
private void bodyPatterns(ResponseActions expect, RequestPattern request) {
	if (request.getBodyPatterns() == null) {
		return;
	}
	for (final ContentPattern<?> pattern : request.getBodyPatterns()) {
		if (pattern instanceof MatchesJsonPathPattern) {
			expect.andExpect(MockRestRequestMatchers
					.jsonPath(((MatchesJsonPathPattern) pattern).getMatchesJsonPath())
					.exists());
		}
		else if (pattern instanceof MatchesXPathPattern) {
			expect.andExpect(xpath((MatchesXPathPattern) pattern));
		}
		expect.andExpect(matchContents(pattern));
	}
}
 
Example #2
Source File: WireMockRestServiceServer.java    From spring-cloud-contract with Apache License 2.0 6 votes vote down vote up
private void requestHeaders(ResponseActions expect, RequestPattern request) {
	if (request.getHeaders() != null) {
		for (final String header : request.getHeaders().keySet()) {
			final MultiValuePattern pattern = request.getHeaders().get(header);
			expect.andExpect(header(header, new BaseMatcher<String>() {

				@Override
				public boolean matches(Object item) {
					return pattern.match(
							new MultiValue(header, Arrays.asList((String) item)))
							.isExactMatch();
				}

				@Override
				public void describeTo(Description description) {
					description
							.appendText("should match header: " + header + " with ")
							.appendText(pattern.getExpected());
				}
			}));
		}
	}
}
 
Example #3
Source File: WireMockRestServiceServer.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
private ResponseActions responseActions(MockRestServiceServer server,
		StubMapping mapping) {
	if (StringUtils.hasText(mapping.getRequest().getUrl())
			|| StringUtils.hasText(mapping.getRequest().getUrlPath())) {
		return server.expect(requestTo(request(mapping.getRequest())));
	}
	return server.expect(requestTo(requestMatcher(mapping.getRequest())));
}
 
Example #4
Source File: GithubServiceTests.java    From github-release-notes-generator with Apache License 2.0 4 votes vote down vote up
private ResponseActions expectGet(String expectedUri) {
	return this.server.expect(requestTo(expectedUri)).andExpect(method(HttpMethod.GET));
}