@@ -50,6 +50,7 @@ public class UpdateExpressionTest extends LocalDynamoDbSyncTestBase {
5050 private static final String NUMBER_ATTRIBUTE_VALUE_REF = ":increment_value_ref" ;
5151 private static final String SET_ATTRIBUTE_REF = "extensionSetAttribute" ;
5252
53+ private static final String TABLE_NAME = "table-name" ;
5354 private static final TableSchema <RecordForUpdateExpressions > TABLE_SCHEMA = TableSchema .fromClass (RecordForUpdateExpressions .class );
5455 private DynamoDbTable <RecordForUpdateExpressions > mappedTable ;
5556
@@ -59,13 +60,16 @@ private void initClientWithExtensions(DynamoDbEnhancedClientExtension... extensi
5960 .extensions (extensions )
6061 .build ();
6162
62- mappedTable = enhancedClient .table (getConcreteTableName ("table-name" ), TABLE_SCHEMA );
63+ mappedTable = enhancedClient .table (getConcreteTableName (TABLE_NAME ), TABLE_SCHEMA );
6364 mappedTable .createTable (r -> r .provisionedThroughput (getDefaultProvisionedThroughput ()));
65+ getDynamoDbClient ().waiter ().waitUntilTableExists (r -> r .tableName (getConcreteTableName (TABLE_NAME )));
6466 }
6567
6668 @ After
6769 public void deleteTable () {
68- getDynamoDbClient ().deleteTable (r -> r .tableName (getConcreteTableName ("table-name" )));
70+ if (mappedTable != null ) {
71+ getDynamoDbClient ().deleteTable (r -> r .tableName (getConcreteTableName (TABLE_NAME )));
72+ }
6973 }
7074
7175 @ Test
@@ -239,9 +243,8 @@ public void chainedExtensions_duplicateAttributes_invalidValueRef_operationMerge
239243
240244 /**
241245 * Tests that explicit UpdateExpression provided on the request prevents REMOVE actions for the referenced attributes.
242- * Normally, null item attributes generate REMOVE actions when ignoreNulls=false.
243- * When an UpdateExpression is provided on the request, REMOVE actions are suppressed for
244- * attributes referenced in that UpdateExpression to avoid conflicts.
246+ * Normally, null item attributes generate REMOVE actions when ignoreNulls=false. When an UpdateExpression is provided on the
247+ * request, REMOVE actions are suppressed for attributes referenced in that UpdateExpression to avoid conflicts.
245248 */
246249 @ Test
247250 public void updateExpressionInRequest_withoutIgnoreNulls_shouldUpdateSuccessfully () {
@@ -259,10 +262,9 @@ public void updateExpressionInRequest_withoutIgnoreNulls_shouldUpdateSuccessfull
259262 }
260263
261264 /**
262- * Tests that explicit UpdateExpression provided on the request works with ignoreNulls=true.
263- * When ignoreNulls=true, null item attributes are ignored and no REMOVE actions are generated.
264- * When an UpdateExpression is provided on the request, it operates independently of the
265- * ignoreNulls setting and updates the specified attributes.
265+ * Tests that explicit UpdateExpression provided on the request works with ignoreNulls=true. When ignoreNulls=true, null item
266+ * attributes are ignored and no REMOVE actions are generated. When an UpdateExpression is provided on the request, it
267+ * operates independently of the ignoreNulls setting and updates the specified attributes.
266268 */
267269 @ Test
268270 public void updateExpressionInRequest_withIgnoreNulls_shouldUpdateSuccessfully () {
@@ -281,8 +283,8 @@ public void updateExpressionInRequest_withIgnoreNulls_shouldUpdateSuccessfully()
281283 }
282284
283285 /**
284- * Tests DynamoDbException is thrown when same attribute is referenced both in the POJO item
285- * and in an explicit UpdateExpression provided on the request
286+ * Tests DynamoDbException is thrown when same attribute is referenced both in the POJO item and in an explicit
287+ * UpdateExpression provided on the request
286288 */
287289 @ Test
288290 public void updateExpressionInRequest_whenAttributeAlsoInPojo_shouldThrowConflictError () {
@@ -299,8 +301,8 @@ public void updateExpressionInRequest_whenAttributeAlsoInPojo_shouldThrowConflic
299301 }
300302
301303 /**
302- * Tests DynamoDbException is thrown when same attribute is referenced both in an extension's UpdateExpression
303- * and in an explicit UpdateExpression provided on the request.
304+ * Tests DynamoDbException is thrown when same attribute is referenced both in an extension's UpdateExpression and in an
305+ * explicit UpdateExpression provided on the request.
304306 */
305307 @ Test
306308 public void updateExpressionInRequest_whenAttributeAlsoInExtension_shouldThrowDynamoDbError () {
@@ -313,7 +315,8 @@ public void updateExpressionInRequest_whenAttributeAlsoInExtension_shouldThrowDy
313315 .addAction (SetAction .builder ()
314316 .path ("extensionNumberAttribute" )
315317 .value (":conflictValue" )
316- .putExpressionValue (":conflictValue" , AttributeValue .builder ().n ("99" ).build ())
318+ .putExpressionValue (":conflictValue" ,
319+ AttributeValue .builder ().n ("99" ).build ())
317320 .build ())
318321 .build ();
319322
@@ -325,9 +328,8 @@ public void updateExpressionInRequest_whenAttributeAlsoInExtension_shouldThrowDy
325328 }
326329
327330 /**
328- * Tests backward compatibility: POJO-only updates should work unchanged.
329- * UpdateExpression functionality is opt-in - without providing an UpdateExpression on the request, behavior is identical
330- * ad before.
331+ * Tests backward compatibility: POJO-only updates should work unchanged. UpdateExpression functionality is opt-in - without
332+ * providing an UpdateExpression on the request, behavior is identical ad before.
331333 */
332334 @ Test
333335 public void backwardCompatibility_pojoOnlyUpdates () {
@@ -344,9 +346,8 @@ public void backwardCompatibility_pojoOnlyUpdates() {
344346 }
345347
346348 /**
347- * Tests backward compatibility: Extension-only updates should work unchanged.
348- * UpdateExpression functionality is opt-in - without providing an UpdateExpression on the request, behavior is identical
349- * as before
349+ * Tests backward compatibility: Extension-only updates should work unchanged. UpdateExpression functionality is opt-in -
350+ * without providing an UpdateExpression on the request, behavior is identical as before
350351 */
351352 @ Test
352353 public void backwardCompatibility_extensionOnlyUpdates () {
@@ -362,8 +363,7 @@ public void backwardCompatibility_extensionOnlyUpdates() {
362363 }
363364
364365 /**
365- * Tests scan() operation
366- * Verifies that scan operations work correctly after update expressions are applied.
366+ * Tests scan() operation Verifies that scan operations work correctly after update expressions are applied.
367367 */
368368 @ Test
369369 public void scanOperation_afterUpdateExpression () {
@@ -394,8 +394,7 @@ public void scanOperation_afterUpdateExpression() {
394394 }
395395
396396 /**
397- * Tests deleteItem() operation
398- * Verifies that items can be deleted after being updated with expressions.
397+ * Tests deleteItem() operation Verifies that items can be deleted after being updated with expressions.
399398 */
400399 @ Test
401400 public void deleteItem_afterUpdateExpression () {
@@ -421,8 +420,7 @@ public void deleteItem_afterUpdateExpression() {
421420 }
422421
423422 /**
424- * Tests batchGetItem() operation
425- * Verifies that batch get operations work correctly after update expressions.
423+ * Tests batchGetItem() operation Verifies that batch get operations work correctly after update expressions.
426424 */
427425 @ Test
428426 public void batchGetItem_afterUpdateExpression () {
@@ -466,8 +464,8 @@ public void batchGetItem_afterUpdateExpression() {
466464 }
467465
468466 /**
469- * Tests batchWriteItem() operation
470- * Verifies that batch write operations work with items that have update expressions applied.
467+ * Tests batchWriteItem() operation Verifies that batch write operations work with items that have update expressions
468+ * applied.
471469 */
472470 @ Test
473471 public void batchWriteItem_withUpdateExpressionItems () {
@@ -504,8 +502,7 @@ public void batchWriteItem_withUpdateExpressionItems() {
504502 }
505503
506504 /**
507- * Tests transactGetItems() operation
508- * Verifies that transactional get operations work after update expressions.
505+ * Tests transactGetItems() operation Verifies that transactional get operations work after update expressions.
509506 */
510507 @ Test
511508 public void transactGetItems_afterUpdateExpression () {
@@ -547,8 +544,7 @@ public void transactGetItems_afterUpdateExpression() {
547544 }
548545
549546 /**
550- * Tests transactWriteItems() operation
551- * Verifies that transactional write operations work correctly.
547+ * Tests transactWriteItems() operation Verifies that transactional write operations work correctly.
552548 */
553549 @ Test
554550 public void transactWriteItems_withUpdateExpression () {
@@ -591,10 +587,12 @@ public void staticTableSchema_withUpdateExpressions() {
591587 .getter (RecordForUpdateExpressions ::getId )
592588 .setter (RecordForUpdateExpressions ::setId )
593589 .tags (primaryPartitionKey ()))
594- .addAttribute (String .class , a -> a .name ("stringAttribute" )
590+ .addAttribute (String .class , a -> a .name (
591+ "stringAttribute" )
595592 .getter (RecordForUpdateExpressions ::getStringAttribute )
596593 .setter (RecordForUpdateExpressions ::setStringAttribute ))
597- .addAttribute (Long .class , a -> a .name ("extensionNumberAttribute" )
594+ .addAttribute (Long .class , a -> a .name (
595+ "extensionNumberAttribute" )
598596 .getter (RecordForUpdateExpressions ::getExtensionNumberAttribute )
599597 .setter (RecordForUpdateExpressions ::setExtensionNumberAttribute ))
600598 .build ();
@@ -613,7 +611,6 @@ public void staticTableSchema_withUpdateExpressions() {
613611 RecordForUpdateExpressions record = new RecordForUpdateExpressions ();
614612 record .setId ("static-test" );
615613 record .setStringAttribute ("init" );
616- // Don't set requestAttributeList to avoid path conflicts with extension
617614
618615 staticTable .updateItem (r -> r .item (record ));
619616
@@ -640,23 +637,29 @@ private void verifySetAttribute(RecordForUpdateExpressions record) {
640637 assertThat (persistedRecord .getExtensionSetAttribute ()).isEqualTo (expectedAttribute );
641638 }
642639
643- /** Creates record with only the partition key (id) */
640+ /**
641+ * Creates record with only the partition key (id)
642+ */
644643 private RecordForUpdateExpressions createKeyOnlyRecord () {
645644 RecordForUpdateExpressions record = new RecordForUpdateExpressions ();
646645 record .setId ("1" );
647646 return record ;
648647 }
649648
650- /** Creates record with POJO attributes (id + stringAttribute) */
649+ /**
650+ * Creates record with POJO attributes (id + stringAttribute)
651+ */
651652 private RecordForUpdateExpressions createSimpleRecord () {
652653 RecordForUpdateExpressions record = new RecordForUpdateExpressions ();
653654 record .setId ("1" );
654655 record .setStringAttribute ("init" );
655656 return record ;
656657 }
657658
658- /** Creates record with POJO + extension + request attributes (requestAttributeList for request UpdateExpressions,
659- * extensionSetAttribute for extension UpdateExpressions) */
659+ /**
660+ * Creates record with POJO + extension + request attributes (requestAttributeList for request UpdateExpressions,
661+ * extensionSetAttribute for extension UpdateExpressions)
662+ */
660663 private RecordForUpdateExpressions createFullRecord () {
661664 RecordForUpdateExpressions record = createSimpleRecord ();
662665 record .setRequestAttributeList (new ArrayList <>(REQUEST_ATTRIBUTES ));
0 commit comments