use of org.springframework.cloud.contract.spec.internal.QueryParameter in project spring-cloud-contract by spring-cloud.
the class CustomModeQueryParamsGiven method addQueryParameters.
private void addQueryParameters(Url buildUrl) {
List<QueryParameter> queryParameters = buildUrl.getQueryParameters().getParameters().stream().filter(this::allowedQueryParameter).collect(Collectors.toList());
Iterator<QueryParameter> iterator = queryParameters.iterator();
while (iterator.hasNext()) {
QueryParameter parameter = iterator.next();
String text = addQueryParameter(parameter);
if (iterator.hasNext()) {
this.blockBuilder.addLine(text);
} else {
this.blockBuilder.addIndented(text);
}
}
}
use of org.springframework.cloud.contract.spec.internal.QueryParameter in project spring-cloud-contract by spring-cloud.
the class JaxRsUrlPathWhen method appendQueryParams.
private void appendQueryParams(QueryParameters queryParameters) {
if (queryParameters == null || queryParameters.getParameters().isEmpty()) {
return;
}
this.blockBuilder.addEmptyLine();
Iterator<QueryParameter> iterator = queryParameters.getParameters().stream().filter(this::allowedQueryParameter).iterator();
while (iterator.hasNext()) {
QueryParameter param = iterator.next();
String queryParamValue = getQueryParamValue(param);
String text = ".queryParam(\"" + param.getName() + "\", " + queryParamValue + ")";
if (iterator.hasNext()) {
this.blockBuilder.addLine(text);
} else {
this.blockBuilder.addIndented(text);
}
}
}
use of org.springframework.cloud.contract.spec.internal.QueryParameter in project spring-cloud-contract by spring-cloud.
the class MockMvcQueryParamsWhen method addQueryParameters.
private void addQueryParameters(Url buildUrl) {
List<QueryParameter> queryParameters = buildUrl.getQueryParameters().getParameters().stream().filter(this::allowedQueryParameter).collect(Collectors.toList());
Iterator<QueryParameter> iterator = queryParameters.iterator();
while (iterator.hasNext()) {
QueryParameter parameter = iterator.next();
String text = addQueryParameter(parameter);
if (iterator.hasNext()) {
this.blockBuilder.addLine(text);
} else {
this.blockBuilder.addIndented(text);
}
}
}
use of org.springframework.cloud.contract.spec.internal.QueryParameter in project spring-cloud-contract by spring-cloud.
the class ContractDslSnippetTests method should_create_contract_template_and_doc_without_body_and_headers.
@Test
public void should_create_contract_template_and_doc_without_body_and_headers() throws Exception {
this.mockMvc.perform(MockMvcRequestBuilders.get("/foo").param("one", "newValueOne").param("two", "newValueTwo")).andExpect(status().isOk()).andDo(document("empty", dslContract()));
then(file("/contracts/empty.groovy")).exists();
then(file("/empty/dsl-contract.adoc")).exists();
Collection<Contract> parsedContracts = ContractVerifierDslConverter.convertAsCollection(new File("/"), file("/contracts/empty.groovy"));
Contract parsedContract = parsedContracts.iterator().next();
then(parsedContract.getRequest().getHeaders()).isNull();
then(parsedContract.getRequest().getMethod().getClientValue()).isNotNull();
then(parsedContract.getRequest().getUrlPath().getClientValue()).isNotNull();
then(parsedContract.getRequest().getUrlPath().getClientValue().toString()).startsWith("/");
List<QueryParameter> parameters = parsedContract.getRequest().getUrlPath().getQueryParameters().getParameters();
QueryParameter one = parameter(parameters, "one");
QueryParameter two = parameter(parameters, "two");
then(one.getClientValue()).isEqualTo("newValueOne");
then(two.getClientValue()).isEqualTo("newValueTwo");
then(parsedContract.getRequest().getBody()).isNull();
then(parsedContract.getResponse().getStatus().getClientValue()).isNotNull();
then(parsedContract.getResponse().getHeaders()).isNull();
then(parsedContract.getResponse().getBody()).isNull();
then(parsedContract.getResponse().getBodyMatchers()).isNull();
}
Aggregations