diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy index f6153341d1..d3365490d0 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy @@ -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 diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcJunitMethodBuilderSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcJunitMethodBuilderSpec.groovy index f3bd466005..0fa9e420f0 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcJunitMethodBuilderSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcJunitMethodBuilderSpec.groovy @@ -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"() {