From 6bd68e552746355ec4ac0b0922c22a6a525a20a9 Mon Sep 17 00:00:00 2001
From: buildmaster
Maven. </plugin>
Gradle.
classpath "com.example:beer-common:0.0.1-SNAPSHOT"-
You can now reference your classes in your DSL, as shown in the following example:
package contracts.beer.rest - -import com.example.ConsumerUtils -import com.example.ProducerUtils -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - description(""" -Represents a successful scenario of getting a beer - -``` -given: - client is old enough -when: - he applies for a beer -then: - we'll grant him the beer -``` - -""") - request { - method 'POST' - url '/check' - body( - age: $(ConsumerUtils.oldEnough()) - ) - headers { - contentType(applicationJson()) - } - } - response { - status 200 - body(""" - { - "status": "${value(ProducerUtils.ok())}" - } - """) - headers { - contentType(applicationJson()) - } - } -}