Bumped jsonassert to 0.4.9
without this change we analyze empty sets of jsonpath results improperly fixes #289
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<description>Spring Cloud Contract Dependencies</description>
|
||||
<properties>
|
||||
<wiremock.version>2.1.7</wiremock.version>
|
||||
<jsonassert.version>0.4.8</jsonassert.version>
|
||||
<jsonassert.version>0.4.9</jsonassert.version>
|
||||
<aether.version>1.0.2.v20150114</aether.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -90,7 +90,7 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
//TODO: Deprecate this since starting with 1.1.x
|
||||
private void addProjectDependencies(Project project) {
|
||||
project.dependencies.add("testCompile", "com.github.tomakehurst:wiremock:2.1.7")
|
||||
project.dependencies.add("testCompile", "com.toomuchcoding.jsonassert:jsonassert:0.4.8")
|
||||
project.dependencies.add("testCompile", "com.toomuchcoding.jsonassert:jsonassert:0.4.9")
|
||||
project.dependencies.add("testCompile", "org.assertj:assertj-core:2.3.0")
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<dependency>
|
||||
<groupId>com.toomuchcoding.jsonassert</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>0.4.8</version>
|
||||
<version>0.4.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<dependency>
|
||||
<groupId>com.toomuchcoding.jsonassert</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>0.4.8</version>
|
||||
<version>0.4.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<dependency>
|
||||
<groupId>com.toomuchcoding.jsonassert</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>0.4.8</version>
|
||||
<version>0.4.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- end::dependencies[] -->
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<dependency>
|
||||
<groupId>com.toomuchcoding.jsonassert</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>0.4.8</version>
|
||||
<version>0.4.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -26,6 +26,8 @@ import spock.lang.Issue
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
|
||||
class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifier {
|
||||
|
||||
@Rule OutputCapture capture = new OutputCapture()
|
||||
@@ -153,4 +155,56 @@ DocumentContext parsedJson = JsonPath.parse(json);
|
||||
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
|
||||
}
|
||||
|
||||
@Issue('#289')
|
||||
def "should fail on nonexistent field [#methodBuilderName]"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url '/something'
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
}
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
}
|
||||
body([
|
||||
doesNotExist: $(p(anyAlphaUnicode()), c("123"))
|
||||
])
|
||||
}
|
||||
}
|
||||
MethodBodyBuilder builder = methodBuilder(contractDsl)
|
||||
BlockBuilder blockBuilder = new BlockBuilder(" ")
|
||||
when:
|
||||
builder.appendTo(blockBuilder)
|
||||
def test = blockBuilder.toString()
|
||||
then:
|
||||
SyntaxChecker.tryToCompile(methodBuilderName, blockBuilder.toString())
|
||||
and:
|
||||
String jsonSample = '''\
|
||||
String json = "{}";
|
||||
DocumentContext parsedJson = JsonPath.parse(json);
|
||||
'''
|
||||
and:
|
||||
LinkedList<String> lines = [] as LinkedList<String>
|
||||
test.eachLine { if (it.contains('assertThatJson')) lines << it else it }
|
||||
lines.addFirst(jsonSample)
|
||||
try {
|
||||
SyntaxChecker.tryToRun(methodBuilderName, lines.join("\n"))
|
||||
} catch (IllegalStateException e) {
|
||||
assert e.message.contains("Parsed JSON [{}] doesn't match the JSON path")
|
||||
} catch (InvocationTargetException e1) {
|
||||
assert e1.cause.message.contains("Parsed JSON [{}] doesn't match the JSON path")
|
||||
}
|
||||
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) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user