@@ -814,6 +814,53 @@ public void itemType_returnsCorrectClassWhenBuiltWithEnhancedType() {
814814 assertThat (tableSchema .itemType (), is (equalTo (EnhancedType .of (FakeMappedItem .class ))));
815815 }
816816
817+ @ Test
818+ public void attributes_varargs_setsAttributesCorrectly () {
819+ StaticAttribute <FakeMappedItem , String > attr1 = StaticAttribute .builder (FakeMappedItem .class , String .class )
820+ .name ("attr1" )
821+ .getter (FakeMappedItem ::getAString )
822+ .setter (FakeMappedItem ::setAString )
823+ .build ();
824+
825+ StaticAttribute <FakeMappedItem , Boolean > attr2 = StaticAttribute .builder (FakeMappedItem .class , Boolean .class )
826+ .name ("attr2" )
827+ .getter (FakeMappedItem ::getABoolean )
828+ .setter (FakeMappedItem ::setABoolean )
829+ .build ();
830+
831+ StaticTableSchema <FakeMappedItem > schema = StaticTableSchema .builder (FakeMappedItem .class )
832+ .newItemSupplier (FakeMappedItem ::new )
833+ .attributes (attr1 , attr2 )
834+ .build ();
835+
836+ FakeMappedItem item = FakeMappedItem .builder ().aString ("test" ).aBoolean (true ).build ();
837+ Map <String , AttributeValue > result = schema .itemToMap (item , false );
838+
839+ assertThat (result .size (), is (2 ));
840+ assertThat (result , hasEntry ("attr1" , AttributeValue .builder ().s ("test" ).build ()));
841+ assertThat (result , hasEntry ("attr2" , AttributeValue .builder ().bool (true ).build ()));
842+ }
843+
844+ @ Test
845+ public void attribute_setsAttributeCorrectly () {
846+ StaticAttribute <FakeMappedItem , String > attr = StaticAttribute .builder (FakeMappedItem .class , String .class )
847+ .name ("attr" )
848+ .getter (FakeMappedItem ::getAString )
849+ .setter (FakeMappedItem ::setAString )
850+ .build ();
851+
852+ StaticTableSchema <FakeMappedItem > schema = StaticTableSchema .builder (FakeMappedItem .class )
853+ .newItemSupplier (FakeMappedItem ::new )
854+ .addAttribute (attr )
855+ .build ();
856+
857+ FakeMappedItem item = FakeMappedItem .builder ().aString ("test" ).aBoolean (true ).build ();
858+ Map <String , AttributeValue > result = schema .itemToMap (item , false );
859+
860+ assertThat (result .size (), is (1 ));
861+ assertThat (result , hasEntry ("attr" , AttributeValue .builder ().s ("test" ).build ()));
862+ }
863+
817864 @ Test
818865 public void getTableMetadata_hasCorrectFields () {
819866 TableMetadata tableMetadata = FakeItemWithSort .getTableSchema ().tableMetadata ();
@@ -1360,7 +1407,7 @@ public void buildAbstractExtends() {
13601407 }
13611408
13621409 @ Test
1363- public void buildAbstractTagWith () {
1410+ public void buildAbstractTagsWith () {
13641411
13651412 StaticTableSchema <FakeDocument > abstractTableSchema =
13661413 StaticTableSchema
@@ -1373,7 +1420,7 @@ public void buildAbstractTagWith() {
13731420 }
13741421
13751422 @ Test
1376- public void buildConcreteTagWith () {
1423+ public void buildConcreteTagsWith () {
13771424
13781425 StaticTableSchema <FakeDocument > concreteTableSchema =
13791426 StaticTableSchema
@@ -1386,6 +1433,58 @@ public void buildConcreteTagWith() {
13861433 is (Optional .of (TABLE_TAG_VALUE )));
13871434 }
13881435
1436+ @ Test
1437+ public void buildAbstractTagsCollection () {
1438+
1439+ StaticTableSchema <FakeDocument > abstractTableSchema =
1440+ StaticTableSchema
1441+ .builder (FakeDocument .class )
1442+ .tags (singletonList (new TestStaticTableTag ()))
1443+ .build ();
1444+
1445+ assertThat (abstractTableSchema .tableMetadata ().customMetadataObject (TABLE_TAG_KEY , String .class ),
1446+ is (Optional .of (TABLE_TAG_VALUE )));
1447+ }
1448+
1449+ @ Test
1450+ public void buildConcreteTagsCollection () {
1451+
1452+ StaticTableSchema <FakeDocument > concreteTableSchema =
1453+ StaticTableSchema
1454+ .builder (FakeDocument .class )
1455+ .newItemSupplier (FakeDocument ::new )
1456+ .tags (singletonList (new TestStaticTableTag ()))
1457+ .build ();
1458+
1459+ assertThat (concreteTableSchema .tableMetadata ().customMetadataObject (TABLE_TAG_KEY , String .class ),
1460+ is (Optional .of (TABLE_TAG_VALUE )));
1461+ }
1462+
1463+ @ Test
1464+ public void buildAbstractAddTag () {
1465+ StaticTableSchema <FakeDocument > abstractTableSchema =
1466+ StaticTableSchema
1467+ .builder (FakeDocument .class )
1468+ .addTag (new TestStaticTableTag ())
1469+ .build ();
1470+
1471+ assertThat (abstractTableSchema .tableMetadata ().customMetadataObject (TABLE_TAG_KEY , String .class ),
1472+ is (Optional .of (TABLE_TAG_VALUE )));
1473+ }
1474+
1475+ @ Test
1476+ public void buildConcreteAddTag () {
1477+ StaticTableSchema <FakeDocument > concreteTableSchema =
1478+ StaticTableSchema
1479+ .builder (FakeDocument .class )
1480+ .newItemSupplier (FakeDocument ::new )
1481+ .addTag (new TestStaticTableTag ())
1482+ .build ();
1483+
1484+ assertThat (concreteTableSchema .tableMetadata ().customMetadataObject (TABLE_TAG_KEY , String .class ),
1485+ is (Optional .of (TABLE_TAG_VALUE )));
1486+ }
1487+
13891488 @ Test
13901489 public void instantiateFlattenedAbstractClassShouldThrowException () {
13911490 StaticTableSchema <FakeAbstractSuperclass > superclassTableSchema =
0 commit comments