Added the missing .timeout(...) method in the generated RestAssured tests

without this change the `fixedDelayMilliseconds` only works for the stub but doesn't do anything in the generated test
with this change we're adding this functionality for MockMvc based tests

fixes #402
This commit is contained in:
Marcin Grzejszczak
2017-08-30 13:02:21 +02:00
parent 113d4e2a4d
commit 15021d3bd1
2 changed files with 33 additions and 0 deletions

View File

@@ -124,6 +124,9 @@ abstract class RequestProcessingMethodBodyBuilder extends MethodBodyBuilder {
if (response.async) {
bb.addLine('.when().async()')
}
if (response.delay) {
bb.addLine(".timeout(${response.delay.serverValue})")
}
}
@TypeChecked(TypeCheckingMode.SKIP)

View File

@@ -315,4 +315,34 @@ DocumentContext parsedJson = JsonPath.parse(json);
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
}
def "should use fixed delay milliseconds in the generated test [#methodBuilderName]"() {
given:
Contract contractDsl = Contract.make {
request {
method GET()
url "test"
}
response {
status 200
async()
fixedDelayMilliseconds(10000)
body(a: 'foo')
}
}
MethodBodyBuilder builder = methodBuilder(contractDsl)
BlockBuilder blockBuilder = new BlockBuilder(" ")
when:
builder.appendTo(blockBuilder)
then:
blockBuilder.toString().contains(""".timeout(10000)""")
and:
SyntaxChecker.tryToCompile(methodBuilderName, blockBuilder.toString())
and:
stubMappingIsValidWireMockStub(contractDsl)
where:
methodBuilderName | methodBuilder
"MockMvcSpockMethodBuilder" | { Contract dsl -> new MockMvcSpockMethodRequestProcessingBodyBuilder(dsl, properties) }
"MockMvcJUnitMethodBuilder" | { Contract dsl -> new MockMvcJUnitMethodBodyBuilder(dsl, properties) }
}
}