pact-jvm-consumer-junit_2.11:2.1.13是否有一种更优雅的方式来声明身体?

时间:2018-01-27 03:07:08

标签: jvm pact

在pact-jvm-consumer-junit_2.10中有这样的:

DslPart part = PactDslJsonArray.arrayEachLike()
            .object("person")
            .integerType("id", 1)
            .stringType("pkey", "STU-12345")
            .stringType("firstname", "Billy")
            .stringType("lastname", "Joe")
            .stringType("grade", "01")
            .closeObject()
            .asBody()
            .array("organizations").object()
            .integerType("id", 1)
            .stringType("name", SCHOOL_NAME)
            .closeObject();

在pact-jvm-consumer-junit_2.10中,我能找到的是:

builder.uponReceiving("a request for Sections")
                .path("/api/1/sections")
                .method("GET")

                .willRespondWith()
                .headers(headers)
                .status(200)
                .body("[{\"value\":42}, {\"value\":100}]").toFragment();

是否不再有一种优雅的方式来定义JSON结构?我道歉,但我看了一遍,我看到的只是2.11的简单例子。

1 个答案:

答案 0 :(得分:0)

可悲的是,不,旧的DSL没有。但是,you're in luck since we have a shiny new DSL which is much better in almost every way by using Java 8's Lambda feature。希望有所帮助。欢呼声。