Skip to content

Commit a4c8529

Browse files
committed
Assert thrown message; use short name
1 parent f43e565 commit a4c8529

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/Extensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ inline fun <reified T : Any> SimpleModule.addDeserializer(kClass: KClass<T>, des
6363

6464
inline fun <reified T> T.throwIfNullableTypeIsNull(): T {
6565
if (null !is T && this == null) {
66-
throw NullInputException(msg = "Cannot deserialize null into non-null object of type ${T::class.java.name}")
66+
throw NullInputException(msg = "Cannot deserialize null into non-null object of type ${T::class.java.simpleName}")
6767
}
6868
return this
6969
}

src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/ExtensionMethodsTests.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
77
import com.fasterxml.jackson.module.kotlin.readValue
88
import org.hamcrest.CoreMatchers.equalTo
99
import org.hamcrest.MatcherAssert.assertThat
10-
import org.junit.Assert.assertNull
1110
import org.junit.Assert.assertThrows
1211
import org.junit.Test
12+
import kotlin.test.assertEquals
1313

1414
class TestExtensionMethods {
1515
val mapper: ObjectMapper = jacksonObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, false)
@@ -43,13 +43,13 @@ class TestExtensionMethods {
4343
assertThat(myList, equalTo(listOf(MyData("value1", 1), MyData("value2", 2))))
4444
}
4545

46-
enum class Options { ONE, TWO }
46+
enum class Options { ONE }
4747

4848
@Test
4949
fun testNullEnumThrows() {
50-
assertThrows(NullInputException::class.java) {
51-
val foo: Options = mapper.readValue("null")
52-
assertNull(foo)
50+
val nullInputException = assertThrows("foo", NullInputException::class.java) {
51+
mapper.readValue<Options>("null")
5352
}
53+
assertEquals("Cannot deserialize null into non-null object of type Options", nullInputException.message)
5454
}
5555
}

0 commit comments

Comments
 (0)