Merge branch '1.2.x'
This commit is contained in:
@@ -2747,38 +2747,4 @@ DocumentContext parsedJson = JsonPath.parse(json);
|
||||
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) } | { String body -> body.contains('assertThat(response.getHeaderString("My-UUID")).isEqualTo(property("my-uuid"));') }
|
||||
}
|
||||
|
||||
@Issue('#554')
|
||||
def "should create an assertion for an empty map or Object for [#methodBuilderName]"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url '/api/v1/xxxx'
|
||||
}
|
||||
response {
|
||||
status OK()
|
||||
body([
|
||||
aMap: ["foo": "bar"],
|
||||
anEmptyMap: [:]
|
||||
])
|
||||
}
|
||||
}
|
||||
MethodBodyBuilder builder = methodBuilder(contractDsl)
|
||||
BlockBuilder blockBuilder = new BlockBuilder(" ")
|
||||
and:
|
||||
builder.appendTo(blockBuilder)
|
||||
String test = blockBuilder.toString()
|
||||
when:
|
||||
SyntaxChecker.tryToRun(methodBuilderName, test.join("\n"))
|
||||
then:
|
||||
test.contains('''assertThatJson(parsedJson).field("['aMap']").field("['foo']").isEqualTo("bar")''')
|
||||
test.contains('''assertThatJson(parsedJson).field("['anEmptyMap']").isEmpty()''')
|
||||
where:
|
||||
methodBuilderName | methodBuilder
|
||||
"MockMvcSpockMethodBuilder" | { Contract dsl -> new MockMvcSpockMethodRequestProcessingBodyBuilder(dsl, properties) }
|
||||
"MockMvcJUnitMethodBuilder" | { Contract dsl -> new MockMvcJUnitMethodBodyBuilder(dsl, properties) }
|
||||
"JaxRsClientSpockMethodRequestProcessingBodyBuilder" | { Contract dsl -> new JaxRsClientSpockMethodRequestProcessingBodyBuilder(dsl, properties) }
|
||||
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -314,6 +314,49 @@ public class WireMockSnippetTests {
|
||||
};
|
||||
}
|
||||
|
||||
private OperationRequest requestPostWithXmlContentType() {
|
||||
return new OperationRequest() {
|
||||
|
||||
@Override
|
||||
public byte[] getContent() {
|
||||
String content = "<name>foo</name>";
|
||||
return content.getBytes(Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentAsString() {
|
||||
return "<name>foo</name>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.add("Content-Type", MediaType.APPLICATION_XML_VALUE);
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return HttpMethod.POST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parameters getParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<OperationRequestPart> getParts() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return URI.create("http://foo/bar");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private OperationRequest requestPostWithEmptyBody() {
|
||||
return new OperationRequest() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user