From 8fcf4c48b49a8e6396e40dd89d3a0206f2d5f26b Mon Sep 17 00:00:00 2001 From: Dries Samyn Date: Tue, 3 Oct 2023 10:01:17 +0100 Subject: [PATCH] PR feedback on use of `assertThrows` vs `assertThatThrownBy` --- .../net/corda/libs/statemanager/api/MetadataTests.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/state-manager/state-manager-api/src/test/kotlin/net/corda/libs/statemanager/api/MetadataTests.kt b/libs/state-manager/state-manager-api/src/test/kotlin/net/corda/libs/statemanager/api/MetadataTests.kt index 8f07513fe3c..337b3130483 100644 --- a/libs/state-manager/state-manager-api/src/test/kotlin/net/corda/libs/statemanager/api/MetadataTests.kt +++ b/libs/state-manager/state-manager-api/src/test/kotlin/net/corda/libs/statemanager/api/MetadataTests.kt @@ -1,9 +1,9 @@ package net.corda.libs.statemanager.api import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertDoesNotThrow -import org.junit.jupiter.api.assertThrows import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.MethodSource import java.util.stream.Stream @@ -29,10 +29,9 @@ class MetadataTests { @Test fun `fail all non-primitive types`() { val list = listOf("Na Na Na Na Na Na Na Na", "Batman") - val ex = assertThrows { - Metadata(mapOf("joker" to Superman(1000), "batman" to list)) - } - assertThat(ex).hasMessageContainingAll("joker", "batman", Superman::class.java.name, list.javaClass.name) + assertThatThrownBy { Metadata(mapOf("joker" to Superman(1000), "batman" to list)) } + .isExactlyInstanceOf(IllegalArgumentException::class.java) + .hasMessageContainingAll("joker", "batman", Superman::class.java.name, list.javaClass.name) } @Test