From d4e731f87b85ae03829bd644ae9ae6823d99364c Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 28 Jun 2016 22:38:29 +0200 Subject: [PATCH] Added a test to ensure that transformer is working fine --- .../StubRunnerStreamTransformerSpec.groovy | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StubRunnerStreamTransformerSpec.groovy b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StubRunnerStreamTransformerSpec.groovy index 15dd47545c..1b53430f1c 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StubRunnerStreamTransformerSpec.groovy +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/stream/StubRunnerStreamTransformerSpec.groovy @@ -92,4 +92,41 @@ class StubRunnerStreamTransformerSpec extends Specification { then: result.payload == '''{"id":"99","temperature":"123.45"}''' } + + def 'should parse dsl without DslProperty'() { + given: + Contract contract = Contract.make { + // Human readable description + description 'Sends an order message' + // Label by means of which the output message can be triggered + label 'send_order' + // input to the contract + input { + // the contract will be triggered by a method + triggeredBy('orderTrigger()') + } + // output message of the contract + outputMessage { + // destination to which the output message will be sent + sentTo('orders') + // any headers for the output message + headers { + header('contentType': 'application/json') + } + // the body of the output message + body( + orderId: value( + consumer('40058c70-891c-4176-a033-f70bad0c5f77'), + producer(regex('([0-9|a-f]*-*)*'))), + description: "This is the order description" + ) + } + } + StubRunnerStreamTransformer streamTransformer = new StubRunnerStreamTransformer(contract) + when: + def result = streamTransformer.transform(message) + then: + result.payload == '''{"orderId":"40058c70-891c-4176-a033-f70bad0c5f77","description":"This is the order description"}''' + } + }