Merge branch '2.1.x'
This commit is contained in:
@@ -34,21 +34,18 @@ class MockMvcAsyncWhen implements When, MockMvcAcceptor {
|
||||
@Override
|
||||
public MethodVisitor<When> apply(SingleContractMetadata metadata) {
|
||||
Response response = metadata.getContract().getResponse();
|
||||
if (response.getAsync()) {
|
||||
this.blockBuilder.addIndented(".when().async()");
|
||||
}
|
||||
addAsync();
|
||||
if (response.getDelay() != null) {
|
||||
String delay = ".timeout(" + response.getDelay().getServerValue() + ")";
|
||||
if (response.getAsync()) {
|
||||
this.blockBuilder.append(delay);
|
||||
}
|
||||
else {
|
||||
this.blockBuilder.addIndented(delay);
|
||||
}
|
||||
this.blockBuilder.append(delay);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void addAsync() {
|
||||
this.blockBuilder.addIndented(".when().async()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(SingleContractMetadata metadata) {
|
||||
boolean accept = acceptType(this.generatedClassMetaData, metadata);
|
||||
|
||||
@@ -365,6 +365,7 @@ class YamlToContracts {
|
||||
async()
|
||||
}
|
||||
if (yamlContract.response.fixedDelayMilliseconds) {
|
||||
async()
|
||||
fixedDelayMilliseconds(yamlContract.response.fixedDelayMilliseconds)
|
||||
}
|
||||
bodyMatchers {
|
||||
|
||||
@@ -1756,6 +1756,83 @@ response:
|
||||
}
|
||||
}
|
||||
|
||||
@Issue("#1262")
|
||||
def "should work with the timeout flag for groovy [#methodBuilderName]"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method(GET())
|
||||
url("/hello")
|
||||
}
|
||||
response {
|
||||
status(200)
|
||||
fixedDelayMilliseconds(5000)
|
||||
}
|
||||
}
|
||||
methodBuilder()
|
||||
when:
|
||||
String test = singleTestGenerator(contractDsl)
|
||||
then:
|
||||
SyntaxChecker.tryToCompileWithoutCompileStatic(methodBuilderName, test)
|
||||
and:
|
||||
test.contains("timeout")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(contractDsl)
|
||||
where:
|
||||
methodBuilderName | methodBuilder
|
||||
"spock" | {
|
||||
properties.testFramework = TestFramework.SPOCK
|
||||
}
|
||||
"mockmvc" | {
|
||||
properties.testMode = TestMode.MOCKMVC
|
||||
}
|
||||
"testNG" | {
|
||||
properties.testFramework = TestFramework.TESTNG
|
||||
}
|
||||
}
|
||||
|
||||
@Issue("#1262")
|
||||
def "should work with the timeout flag for yaml [#methodBuilderName]"() {
|
||||
given:
|
||||
String yaml = '''\
|
||||
request:
|
||||
method: GET
|
||||
url: /hello
|
||||
queryParameters:
|
||||
name: LuLu
|
||||
response:
|
||||
status: 200
|
||||
fixedDelayMilliseconds: 5000
|
||||
body: "Hello LuLu"
|
||||
async: true
|
||||
'''
|
||||
File tmpFile = File.createTempFile("foo", ".yml")
|
||||
tmpFile.createNewFile()
|
||||
tmpFile.text = yaml
|
||||
Contract contractDsl = new YamlContractConverter().convertFrom(tmpFile).
|
||||
first()
|
||||
methodBuilder()
|
||||
when:
|
||||
String test = singleTestGenerator(contractDsl)
|
||||
then:
|
||||
SyntaxChecker.tryToCompileWithoutCompileStatic(methodBuilderName, test)
|
||||
and:
|
||||
test.contains("timeout")
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(contractDsl)
|
||||
where:
|
||||
methodBuilderName | methodBuilder
|
||||
"spock" | {
|
||||
properties.testFramework = TestFramework.SPOCK
|
||||
}
|
||||
"mockmvc" | {
|
||||
properties.testMode = TestMode.MOCKMVC
|
||||
}
|
||||
"testNG" | {
|
||||
properties.testFramework = TestFramework.TESTNG
|
||||
}
|
||||
}
|
||||
|
||||
@Issue("#1049")
|
||||
def "should work with body having new lines [#methodBuilderName]"() {
|
||||
given:
|
||||
|
||||
Reference in New Issue
Block a user