use of org.springframework.cloud.contract.spec.internal.Url in project spring-cloud-contract by spring-cloud.
the class ContractsToYaml method request.
protected void request(Contract contract, YamlContract yamlContract) {
Request request = contract.getRequest();
if (request != null) {
ContentType requestContentType = evaluateClientSideContentType(request.getHeaders(), request.getBody());
yamlContract.request = new YamlContract.Request();
mapRequestMethod(yamlContract.request, request);
mapRequestUrl(yamlContract.request, request);
mapRequestUrlPath(yamlContract.request, request);
mapRequestMatchers(yamlContract.request);
Url requestUrl = Optional.ofNullable(request.getUrl()).orElse(request.getUrlPath());
if (requestUrl.getQueryParameters() != null) {
mapRequestQueryParameters(yamlContract.request, requestUrl);
mapRequestMatchersQueryParameters(yamlContract.request, requestUrl);
}
mapRequestHeaders(yamlContract.request, request);
mapRequestCookies(yamlContract.request, request);
mapRequestBody(yamlContract.request, request);
mapRequestMultipart(yamlContract.request, request);
mapRequestMatchersBody(yamlContract.request, request);
mapRequestMatchersUrl(yamlContract.request, request);
mapRequestMatchersMultipart(yamlContract.request, request);
// TODO: Cookie matchers - including absent
if (XML != requestContentType) {
setInputBodyMatchers(request.getBody(), yamlContract.request.matchers.body);
}
setInputHeadersMatchers(request.getHeaders(), yamlContract.request.matchers.headers);
}
}
use of org.springframework.cloud.contract.spec.internal.Url in project spring-cloud-contract by spring-cloud.
the class WireMockRequestStubStrategy method appendQueryParameters.
private void appendQueryParameters(RequestPatternBuilder requestPattern) {
QueryParameters queryParameters = Optional.ofNullable(request).map(Request::getUrlPath).map(Url::getQueryParameters).orElseGet(() -> Optional.ofNullable(request).map(Request::getUrl).map(Url::getQueryParameters).orElse(null));
Optional.ofNullable(queryParameters).map(QueryParameters::getParameters).ifPresent(parameters -> parameters.forEach(parameter -> requestPattern.withQueryParam(parameter.getName(), (StringValuePattern) convertToValuePattern(parameter.getClientValue()))));
}
use of org.springframework.cloud.contract.spec.internal.Url in project spring-cloud-contract by spring-cloud.
the class MockMvcQueryParamsWhen method accept.
@Override
public boolean accept(SingleContractMetadata metadata) {
Request request = metadata.getContract().getRequest();
Url url = getUrl(request);
return url.getQueryParameters() != null;
}
use of org.springframework.cloud.contract.spec.internal.Url in project spring-cloud-contract by spring-cloud.
the class CustomModeQueryParamsGiven method apply.
@Override
public MethodVisitor<Given> apply(SingleContractMetadata metadata) {
Request request = metadata.getContract().getRequest();
Url url = getUrl(request);
addQueryParameters(url);
return this;
}
use of org.springframework.cloud.contract.spec.internal.Url in project spring-cloud-contract by spring-cloud.
the class MockMvcQueryParamsWhen method apply.
@Override
public MethodVisitor<When> apply(SingleContractMetadata metadata) {
Request request = metadata.getContract().getRequest();
Url url = getUrl(request);
addQueryParameters(url);
return this;
}
Aggregations