如何在WireMock中匹配JSON正文中的数组字段?

问题描述

我一直在尝试使用wiremock验证http请求是否已发送到外部服务。 我想将字符串数组传递给util方法,它是请求字段之一。但是我不断收到不同的错误。 到目前为止,我已经尝试过:

    static verifyRequestSent(List<String> someValues) {
        verify(putRequestedFor(urlEqualTo("/someUrl"))
                .withRequestBody(containing("\"field\":${someValues.toString()}".toString()))
        )
    }
    static verifyRequestSent(List<String> someValues) {
        verify(putRequestedFor(urlEqualTo("/someUrl"))
                .withRequestBody(equalToJson("""
                    {
                        "field": $someValues
                    }
                    """)
                )
        )
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)