Pact JVM V4Pact how to use PactBuilder with new API?

118 views Asked by At

I upgraded to Pact JVM. Version "4.6.3"
Now my method in Consumer test looks like this (It is in Kotlin, but Java implementation will look quite similar):

    @Pact(provider = "ArticlesProvider", consumer = "ArticlesConsumer")
    fun createPact(builder: PactBuilder): V4Pact {
        return builder
            .usingLegacyDsl()
            .given("Provider with three articles")
            .uponReceiving("ListAllArticles")
            .path("/articles.json")
            .method("GET")
            .willRespondWith()
            .status(200)
            .body(
                """
                    {
                      "articles" : [ {
                        "name" : "Basic news",
                        "length" : 104
                      }, {
                        "name" : "About dogs",
                        "length" : 5684
                      }, {
                        "name" : "Gossip",
                        "length" : 4512384
                      } ]
                    }
                """.trimIndent()
            )
            .toPact(V4Pact::class.java)
    }

I wonder how I should use builder without using usingLegacyDsl(). What is a new way to specify this?

I may be dull, but I was trying to find some good samples/documentation for the new API but with no luck.

0

There are 0 answers