From de8e71815116c9103952985753d6d186d7bf8bfb Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 2 Jan 2024 11:31:08 +0530 Subject: [PATCH] chore : fix ambigous references to assertThatThrownBy Signed-off-by: Rohan Kumar --- .../mock/crud/KubernetesCrudDispatcherPatchTest.java | 8 ++++---- .../kubernetes/client/http/StandardHttpClientTest.java | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherPatchTest.java b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherPatchTest.java index 9933708a6b5..21bd983f6f7 100644 --- a/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherPatchTest.java +++ b/junit/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/crud/KubernetesCrudDispatcherPatchTest.java @@ -36,6 +36,7 @@ import java.util.function.UnaryOperator; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -319,11 +320,10 @@ void differentResourceVersionConflictEdit() { .addToData("key", "changed") .build()); // Then - assertThatThrownBy(patchedCmOp::patch) - .asInstanceOf(InstanceOfAssertFactories.type(KubernetesClientException.class)) + assertThatExceptionOfType(KubernetesClientException.class) + .isThrownBy(patchedCmOp::patch) .hasFieldOrPropertyWithValue("code", 409) - .extracting(KubernetesClientException::getMessage).asString() - .contains("the object has been modified;"); + .withMessageContaining("the object has been modified;"); } @Test diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/StandardHttpClientTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/StandardHttpClientTest.java index f3664e9e9d4..feefd0a4b5c 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/StandardHttpClientTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/StandardHttpClientTest.java @@ -41,6 +41,7 @@ import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -231,8 +232,9 @@ void testRequestTimeout() { }); Awaitility.await().atMost(10, TimeUnit.SECONDS).until(consumeFuture::isDone); - assertThatThrownBy(consumeFuture::get) - .isInstanceOf(ExecutionException.class).hasCauseInstanceOf(TimeoutException.class); + assertThatExceptionOfType(ExecutionException.class) + .isThrownBy(consumeFuture::get) + .withCauseExactlyInstanceOf(TimeoutException.class); } @Test