From b98d5a696315703025bece65b7e846f304c34b9a Mon Sep 17 00:00:00 2001 From: Albert Latacz Date: Tue, 2 Jan 2024 23:04:16 +0000 Subject: [PATCH] added test for no such field in nested type --- .../kotlin/dev/forkhandles/lens/JacksonWrapperTest.kt | 8 +++++--- .../test/kotlin/dev/forkhandles/lens/MapWrapperTest.kt | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lens4k/src/test/kotlin/dev/forkhandles/lens/JacksonWrapperTest.kt b/lens4k/src/test/kotlin/dev/forkhandles/lens/JacksonWrapperTest.kt index 5a167b0..466d681 100644 --- a/lens4k/src/test/kotlin/dev/forkhandles/lens/JacksonWrapperTest.kt +++ b/lens4k/src/test/kotlin/dev/forkhandles/lens/JacksonWrapperTest.kt @@ -10,8 +10,9 @@ import strikt.assertions.message class JacksonWrapperTest { - class SubMap(node: JsonNode) : JacksonWrapper(node) { + class SubNodeBacked(node: JsonNode) : JacksonWrapper(node) { val stringField by Field() + val noSuchField by Field() } class NodeBacked(node: JsonNode) : JacksonWrapper(node) { @@ -22,9 +23,9 @@ class JacksonWrapperTest { val decimalField by Field() val notAStringField by Field() val noSuchField by Field() - val listField by ListField(::SubMap) + val listField by ListField(::SubNodeBacked) val listField2 by ListField(Any::toString) - val objectField by ObjectField(::SubMap) + val objectField by ObjectField(::SubNodeBacked) } @Test @@ -62,5 +63,6 @@ class JacksonWrapperTest { expectThat(mapBacked.objectField.stringField).isEqualTo("string") expectThrows { mapBacked.notAStringField }.message.isEqualTo("Value for field is not a class kotlin.String but class kotlin.Int") expectThrows { mapBacked.noSuchField }.message.isEqualTo("Field is missing") + expectThrows { mapBacked.objectField.noSuchField }.message.isEqualTo("Field is missing") } } diff --git a/lens4k/src/test/kotlin/dev/forkhandles/lens/MapWrapperTest.kt b/lens4k/src/test/kotlin/dev/forkhandles/lens/MapWrapperTest.kt index dbc400b..e8114d7 100644 --- a/lens4k/src/test/kotlin/dev/forkhandles/lens/MapWrapperTest.kt +++ b/lens4k/src/test/kotlin/dev/forkhandles/lens/MapWrapperTest.kt @@ -10,6 +10,7 @@ class MapWrapperTest { class SubMap(propertySet: Map) : MapWrapper(propertySet) { val stringField by Field() + val noSuchField by Field() } class MapBacked(propertySet: Map) : MapWrapper(propertySet) { @@ -56,5 +57,6 @@ class MapWrapperTest { expectThat(mapBacked.objectField.stringField).isEqualTo("string") expectThrows { mapBacked.notAStringField }.message.isEqualTo("Value for field is not a class kotlin.String but class kotlin.Int") expectThrows { mapBacked.noSuchField }.message.isEqualTo("Field is missing") + expectThrows { mapBacked.objectField.noSuchField }.message.isEqualTo("Field is missing") } }