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:
@@ -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)
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user