Skip to content

Commit

Permalink
PR feedback on use of assertThrows vs assertThatThrownBy
Browse files Browse the repository at this point in the history
  • Loading branch information
driessamyn committed Oct 3, 2023
1 parent 5171e1c commit 8fcf4c4
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<IllegalArgumentException> {
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
Expand Down

0 comments on commit 8fcf4c4

Please sign in to comment.