Skip to content

Commit

Permalink
Merge branch '3.1.x' into 4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Sep 5, 2023
2 parents 518c469 + 7975d43 commit 948532c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ else if (bodyValue instanceof List) {
.map(o -> convertUnicodeEscapesIfRequired(MapConverter.getTestSideValuesForText(o).toString()))
.collect(Collectors.joining("&")).toString();
}
else if (bodyValue instanceof String) {
return (String) bodyValue;
}
}
else {
return convertToJsonString(bodyValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2233,4 +2233,52 @@ response:
properties.testFramework = TestFramework.TESTNG
} | '\$'
}

@Issue("1808")
def "should correctly work with Form URL encoded request body"() {
given:
Contract contractDsl = Contract.make {
request {
method 'POST'
url '/exportData'
headers {
header("Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8')
}
body('fromDt=16-Aug-2023&toDt=25-Aug-2023')
}
response {
status 200
}
}

methodBuilder()
when:
String test = singleTestGenerator(contractDsl)
then:
SyntaxChecker.tryToCompile(methodBuilderName, test)
then:
testAssertion(test)
and:
stubMappingIsValidWireMockStub(contractDsl)
where:
methodBuilderName | methodBuilder | testAssertion
"spock" | {
properties.testFramework = TestFramework.SPOCK
} | { it -> it.contains(""".body('''fromDt=16-Aug-2023&toDt=25-Aug-2023''')""")}
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
} | { it -> it.contains(""".body("fromDt=16-Aug-2023&toDt=25-Aug-2023")""")}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
} | { it -> it.contains('.build("POST", entity("fromDt=16-Aug-2023&toDt=25-Aug-2023", "application/x-www-form-urlencoded; charset=UTF-8"))')}
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
} | { it -> it.contains('.build("POST", entity("fromDt=16-Aug-2023&toDt=25-Aug-2023", "application/x-www-form-urlencoded; charset=UTF-8"))')}
"webclient" | {
properties.testMode = TestMode.WEBTESTCLIENT
} | { it -> it.contains('.body("fromDt=16-Aug-2023&toDt=25-Aug-2023")') }
"testNG" | {
properties.testFramework = TestFramework.TESTNG
} | { it -> it.contains('.body("fromDt=16-Aug-2023&toDt=25-Aug-2023")') }
}
}

0 comments on commit 948532c

Please sign in to comment.