Home > Net >  In Testcase statment gives error after upgrading the springboot version from 2.1.7 to 2.6.4
In Testcase statment gives error after upgrading the springboot version from 2.1.7 to 2.6.4

Time:06-08

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

CodePudding user response:

You are likely hitting https://github.com/assertj/assertj-core/issues/2357.

For workarounds see:

CodePudding user response:

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))
                    }
    )
  • Related