1919import static org .assertj .core .api .Assertions .assertThatThrownBy ;
2020import static software .amazon .awssdk .enhanced .dynamodb .internal .AttributeValues .stringValue ;
2121
22- import java .util .Arrays ;
2322import java .util .Collection ;
24- import java .util .Objects ;
2523import java .util .function .Function ;
2624
2725import org .assertj .core .api .Assertions ;
3533import software .amazon .awssdk .enhanced .dynamodb .Expression ;
3634import software .amazon .awssdk .enhanced .dynamodb .Key ;
3735import software .amazon .awssdk .enhanced .dynamodb .TableSchema ;
38- import software .amazon .awssdk .enhanced .dynamodb .functionaltests .models .AbstractBean ;
39- import software .amazon .awssdk .enhanced .dynamodb .functionaltests .models .AbstractImmutable ;
40- import software .amazon .awssdk .enhanced .dynamodb .functionaltests .models .SimpleBean ;
41- import software .amazon .awssdk .enhanced .dynamodb .functionaltests .models .SimpleImmutable ;
4236import software .amazon .awssdk .enhanced .dynamodb .model .DeleteItemEnhancedRequest ;
4337import software .amazon .awssdk .enhanced .dynamodb .model .DeleteItemEnhancedResponse ;
4438import software .amazon .awssdk .enhanced .dynamodb .model .DescribeTableEnhancedResponse ;
@@ -60,32 +54,7 @@ public class AnnotatedTableSchemaTest extends LocalDynamoDbSyncTestBase {
6054
6155 @ Parameterized .Parameters (name = "{0}" )
6256 public static Collection <Object []> parameters () {
63- return Arrays .asList (new Object [][] {
64- {
65- "@DynamoDbBean" ,
66- SimpleBean .class ,
67- TableSchema .fromClass (SimpleBean .class ),
68- (Function <TestItemFactory , Object >) TestItemFactory ::bean ,
69- (Function <TestItemFactory , Object >) TestItemFactory ::beanPartial ,
70- (Function <TestItemFactory , Object >) TestItemFactory ::beanItem1 ,
71- (Function <TestItemFactory , Object >) TestItemFactory ::beanItem2 ,
72- (Function <TestItemFactory , Object >) TestItemFactory ::beanUpdated ,
73- (Function <TestItemFactory , Object >) TestItemFactory ::beanUpdatedNullString ,
74- AbstractBean .class
75- },
76- {
77- "@DynamoDbImmutable" ,
78- SimpleImmutable .class ,
79- TableSchema .fromClass (SimpleImmutable .class ),
80- (Function <TestItemFactory , Object >) TestItemFactory ::immutable ,
81- (Function <TestItemFactory , Object >) TestItemFactory ::immutablePartial ,
82- (Function <TestItemFactory , Object >) TestItemFactory ::immutableItem1 ,
83- (Function <TestItemFactory , Object >) TestItemFactory ::immutableItem2 ,
84- (Function <TestItemFactory , Object >) TestItemFactory ::immutableUpdated ,
85- (Function <TestItemFactory , Object >) TestItemFactory ::immutableUpdatedNullString ,
86- AbstractImmutable .class
87- }
88- });
57+ return AnnotatedTableSchemaTestSupport .parameters ();
8958 }
9059
9160 @ Parameterized .Parameter (0 )
@@ -98,22 +67,22 @@ public static Collection<Object[]> parameters() {
9867 public TableSchema <Object > tableSchema ;
9968
10069 @ Parameterized .Parameter (3 )
101- public Function <TestItemFactory , Object > fullItem ;
70+ public Function <AnnotatedTableSchemaTestSupport . TestItemFactory , Object > fullItem ;
10271
10372 @ Parameterized .Parameter (4 )
104- public Function <TestItemFactory , Object > partialItem ;
73+ public Function <AnnotatedTableSchemaTestSupport . TestItemFactory , Object > partialItem ;
10574
10675 @ Parameterized .Parameter (5 )
107- public Function <TestItemFactory , Object > firstItem ;
76+ public Function <AnnotatedTableSchemaTestSupport . TestItemFactory , Object > firstItem ;
10877
10978 @ Parameterized .Parameter (6 )
110- public Function <TestItemFactory , Object > secondItem ;
79+ public Function <AnnotatedTableSchemaTestSupport . TestItemFactory , Object > secondItem ;
11180
11281 @ Parameterized .Parameter (7 )
113- public Function <TestItemFactory , Object > updatedItem ;
82+ public Function <AnnotatedTableSchemaTestSupport . TestItemFactory , Object > updatedItem ;
11483
11584 @ Parameterized .Parameter (8 )
116- public Function <TestItemFactory , Object > updatedItemWithNullString ;
85+ public Function <AnnotatedTableSchemaTestSupport . TestItemFactory , Object > updatedItemWithNullString ;
11786
11887 @ Parameterized .Parameter (9 )
11988 public Class <?> abstractItemClass ;
@@ -123,13 +92,13 @@ public static Collection<Object[]> parameters() {
12392 .build ();
12493
12594 private DynamoDbTable <Object > mappedTable ;
126- private TestItemFactory factory ;
95+ private AnnotatedTableSchemaTestSupport . TestItemFactory factory ;
12796
12897 @ Before
12998 public void createTable () {
13099 mappedTable = enhancedClient .table (getConcreteTableName (TABLE_NAME ), tableSchema );
131100 mappedTable .createTable (r -> r .provisionedThroughput (getDefaultProvisionedThroughput ()));
132- factory = new TestItemFactory ();
101+ factory = new AnnotatedTableSchemaTestSupport . TestItemFactory ();
133102 }
134103
135104 @ After
@@ -600,114 +569,5 @@ public void deleteItemWithResponse_itemNotFound_returnsNullValue() {
600569
601570 assertThat (deleteItemEnhancedResponse .attributes ()).isNull ();
602571 }
603-
604- private static final class TestItemFactory {
605- private final String id = "id-value" ;
606- private final String sort = "sort-value" ;
607-
608- Object bean () {
609- SimpleBean item = new SimpleBean ();
610- item .setId (id );
611- item .setSort (sort );
612- item .setStringAttribute ("stringAttribute-value" );
613- return item ;
614- }
615-
616- Object beanPartial () {
617- SimpleBean item = new SimpleBean ();
618- item .setId (id );
619- item .setSort (sort );
620- return item ;
621- }
622-
623- Object beanItem1 () {
624- SimpleBean item = new SimpleBean ();
625- item .setId (id );
626- item .setSort (sort );
627- item .setStringAttribute ("stringAttribute-value-item1" );
628- return item ;
629- }
630-
631- Object beanItem2 () {
632- SimpleBean item = new SimpleBean ();
633- item .setId (id );
634- item .setSort (sort );
635- item .setStringAttribute ("stringAttribute-value-item2" );
636- return item ;
637- }
638-
639- Object beanUpdated () {
640- SimpleBean item = new SimpleBean ();
641- item .setId (id );
642- item .setSort (sort );
643- item .setStringAttribute ("stringAttribute-value-updated" );
644- return item ;
645- }
646-
647- Object beanUpdatedNullString () {
648- SimpleBean item = new SimpleBean ();
649- item .setId (id );
650- item .setSort (sort );
651- item .setStringAttribute (null );
652- return item ;
653- }
654-
655- Object immutable () {
656- return SimpleImmutable .builder ()
657- .id (id )
658- .sort (sort )
659- .stringAttribute ("stringAttribute-value" )
660- .build ();
661- }
662-
663- Object immutablePartial () {
664- return SimpleImmutable .builder ()
665- .id (id )
666- .sort (sort )
667- .build ();
668- }
669-
670- Object immutableItem1 () {
671- return SimpleImmutable .builder ()
672- .id (id )
673- .sort (sort )
674- .stringAttribute ("stringAttribute-value-item1" )
675- .build ();
676- }
677-
678- Object immutableItem2 () {
679- return SimpleImmutable .builder ()
680- .id (id )
681- .sort (sort )
682- .stringAttribute ("stringAttribute-value-item2" )
683- .build ();
684- }
685-
686- Object immutableUpdated () {
687- return SimpleImmutable .builder ()
688- .id (id )
689- .sort (sort )
690- .stringAttribute ("stringAttribute-value-updated" )
691- .build ();
692- }
693-
694- Object immutableUpdatedNullString () {
695- return SimpleImmutable .builder ()
696- .id (id )
697- .sort (sort )
698- .stringAttribute (null )
699- .build ();
700- }
701-
702- @ Override
703- public boolean equals (Object o ) {
704- return super .equals (o );
705- }
706-
707- @ Override
708- public int hashCode () {
709- return Objects .hash (id , sort );
710- }
711- }
712572}
713573
0 commit comments