Fixed handling execution properties in JUnit tests.

This commit is contained in:
Olga Maciaszek-Sharma
2016-02-21 18:00:24 +01:00
parent d2a6044b36
commit 57c030189b
2 changed files with 9 additions and 4 deletions

View File

@@ -64,7 +64,14 @@ abstract class JUnitMethodBodyBuilder extends MethodBodyBuilder {
@Override
protected void processBodyElement(BlockBuilder blockBuilder, String property, Map.Entry entry) {
processBodyElement(blockBuilder, property + """.get(\\\"$entry.key\\\")""", entry.value)
processBodyElement(blockBuilder, property + getMapKeyReferenceString(entry), entry.value)
}
private String getMapKeyReferenceString(Map.Entry entry) {
if (entry.value instanceof ExecutionProperty){
return "." + entry.key
}
return """.get(\\\"$entry.key\\\")"""
}
@Override

View File

@@ -740,8 +740,6 @@ class MockMvcJunitMethodBuilderSpec extends Specification implements WireMockStu
}
@Issue('72')
@Ignore
//TODO: fix exec method for jUnit
def "should make the execute method work"() {
given:
GroovyDsl contractDsl = GroovyDsl.make {
@@ -781,7 +779,7 @@ class MockMvcJunitMethodBuilderSpec extends Specification implements WireMockStu
builder.appendTo(blockBuilder)
def jUnitTest = blockBuilder.toString()
then:
jUnitTest.contains('''assertThatRejectionReasonIsNull(parsedJson.read('$.rejectionReason'))''')
jUnitTest.contains('''assertThatRejectionReasonIsNull(parsedJson.read("$.rejectionReason"))''')
}
def "should support inner map and list definitions"() {