在TestCase Statment中,在将Springboot版本从2.1.7升级到2.6.4之后会出现错误。

发布于 2025-02-04 14:38:47 字数 2016 浏览 3 评论 0 原文

遇到错误

@Test
fun `Should include id in all outbound requests`() {
    (authenticationSource as TestAuthenticationSource).setCoordinatorToken()
    val request = PersonSearch().apply {
        firstName = “Xyz”
        lastName = “Abc”
    }
    val oid = UUID.randomUUID().toString()

    client
            .post()
            .uri("/v/search/outbound")
            .headers {
                it.setBearerAuth("fakeToken")
                it.set(CORRELATION_ID, oid)
            }
            .body(Mono.just(request), PersonSearch::class.java)
            .exchange()

    assertThat(server.requestCount).isEqualTo(2)
   // The bellow line give error while it was working fine in previous version 
    assertThat(server.takeAllRequests()).allSatisfy { assertThat(it.headers.toMultimap()).containsEntry(CORRELATION_ID, listOf(oid)) }

  // Trying in this way as well
    assertThat(server.takeAllRequests()).allSatisfy { it -> assertThat(it.headers.toMultimap()).containsEntry(CORRELATION_ID, listOf(oid)) }
}

弹簧启动版本更新为2.6.4 我在旧版本2.1.7 中 >显示第一行AS -

Overload resolution ambiguity. All these functions match.
public open fun allSatisfy(requirements: Consumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert
public open fun allSatisfy(requirements: ThrowingConsumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert

虽然它在运行时抛出相同的 exception 消息 -

Kotlin: Overload resolution ambiguity: 
public open fun allSatisfy(p0: Consumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert
public open fun allSatisfy(p0: ThrowingConsumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert

After updating the Spring Boot version to 2.6.4 I am getting error in the test case while in its old version 2.1.7 working fine

@Test
fun `Should include id in all outbound requests`() {
    (authenticationSource as TestAuthenticationSource).setCoordinatorToken()
    val request = PersonSearch().apply {
        firstName = “Xyz”
        lastName = “Abc”
    }
    val oid = UUID.randomUUID().toString()

    client
            .post()
            .uri("/v/search/outbound")
            .headers {
                it.setBearerAuth("fakeToken")
                it.set(CORRELATION_ID, oid)
            }
            .body(Mono.just(request), PersonSearch::class.java)
            .exchange()

    assertThat(server.requestCount).isEqualTo(2)
   // The bellow line give error while it was working fine in previous version 
    assertThat(server.takeAllRequests()).allSatisfy { assertThat(it.headers.toMultimap()).containsEntry(CORRELATION_ID, listOf(oid)) }

  // Trying in this way as well
    assertThat(server.takeAllRequests()).allSatisfy { it -> assertThat(it.headers.toMultimap()).containsEntry(CORRELATION_ID, listOf(oid)) }
}

In error is shows the first line as -

Overload resolution ambiguity. All these functions match.
public open fun allSatisfy(requirements: Consumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert
public open fun allSatisfy(requirements: ThrowingConsumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert

While it throws same exception Message when running -

Kotlin: Overload resolution ambiguity: 
public open fun allSatisfy(p0: Consumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert
public open fun allSatisfy(p0: ThrowingConsumer<in RecordedRequest!>!): ObjectArrayAssert<RecordedRequest!>! defined in org.assertj.core.api.ObjectArrayAssert

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅唱々樱花落 2025-02-11 14:38:47

如此url assertj-core/desission/dessise/2357 由@joel Costigliola建议在完全满意以消除歧义之后,我进行了一些小的更改,只是消费者键。

assertThat(server.takeAllRequests())
    .allSatisfy( 
                Consumer {  // added part
                        assertThat(it.headers.toMultimap()).containsEntry(CORRELATION_ID, listOf(cId))
                    }
    )

As in this url assertj-core/issues/2357 suggested by @Joel Costigliola I have made small changes just added Consumer key after allSatisfy to eliminate the ambiguity.

assertThat(server.takeAllRequests())
    .allSatisfy( 
                Consumer {  // added part
                        assertThat(it.headers.toMultimap()).containsEntry(CORRELATION_ID, listOf(cId))
                    }
    )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文