Skip to content

Commit 16d4ad7

Browse files
committed
additional unit test to verify behavior of SimpleItemConverter` in a key-attributes-only scenario
1 parent 1ed0252 commit 16d4ad7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

hll/dynamodb-mapper/dynamodb-mapper/common/test/aws/sdk/kotlin/hll/dynamodbmapper/items/SimpleItemConverterTest.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlin.test.assertTrue
1313

1414
class SimpleItemConverterTest {
1515
@Test
16-
fun testSomething() {
16+
fun testBasicConversion() {
1717
val converter = SimpleItemConverter(
1818
::ProductBuilder,
1919
ProductBuilder::build,
@@ -33,6 +33,24 @@ class SimpleItemConverterTest {
3333
val unconverted = converter.convertFrom(item)
3434
assertEquals(foo, unconverted)
3535
}
36+
37+
@Test
38+
fun testKeyOnlyConversion() {
39+
val converter = SimpleItemConverter(
40+
::ProductBuilder,
41+
ProductBuilder::build,
42+
AttributeDescriptor("id", Product::id, ProductBuilder::id::set, IntConverter),
43+
AttributeDescriptor("name", Product::name, ProductBuilder::name::set, StringConverter),
44+
AttributeDescriptor("in-stock", Product::inStock, ProductBuilder::inStock::set, BooleanConverter),
45+
)
46+
47+
val foo = Product(42, "Foo 2.0", inStock = true)
48+
val item = converter.convertTo(foo, setOf("id", "name"))
49+
50+
assertEquals(2, item.size)
51+
assertEquals(42, item.getValue("id").asN().toInt())
52+
assertEquals("Foo 2.0", item.getValue("name").asS())
53+
}
3654
}
3755

3856
private data class Product(

0 commit comments

Comments
 (0)