Spring 云合约错误'期望等于 <generated> 关闭

Spring cloud contract error 'expecting to be equal to <generated> closure

我的合同是用 groovy 写的。 我有带有 UUID 的请求正文,响应是(另一个随机的)UUID。

Contract.make {
    description "Should create configuration"
    request {
        method 'POST'
        url '/configuration'
        body(
       childBranch: $(consumer(regex(uuid()))),       
    )
        headers {
            header (HttpHeaders.CONTENT_TYPE, new NotToEscapePattern(~'application/json;.*charset=UTF-8.*')) 
        }
    }
    response {
        status HttpStatus.CREATED.value()
        body(${consumer(regex(uuid()))})
    }
}

运行gradle任务generateContractTests 产生 java class 具有

    assertThat(responseBody)
.isEqualTo("shouldConfigure$_run_closure1$_closure3$_closure5@6a1d0a91");

运行 中的测试 class 产生

Expecting:
 <""61af388b-d4f8-4eff-ad84-3cb8720138cb"">
to be equal to:
 <"shouldConfigure$_run_closure1$_closure3$_closure5@6a1d0a91">
but was not.

我的合同有什么问题?如何为我的案例正确编写和 运行 合同?

Cześć :) 你真的不应该调用 NotToEscapePattern。问题是在响应中你有 body(${consumer(regex(uuid()))}),你应该有 body($(producer(regex(uuid()))))