@@ -311,7 +311,7 @@ public void updateItemConditionTestFailure() {
311
311
}
312
312
313
313
// ======================================================================
314
- // SCENARIO 1: UpdateItem → UpdateItem
314
+ // SCENARIO 1: PutItem → UpdateItem → UpdateItem
315
315
// Case A: UUIDs are not provided in request payload
316
316
// createdUuid stays the same across updates (UpdateBehaviour.WRITE_IF_NOT_EXISTS)
317
317
// lastUpdatedUuid changes on every update (UpdateBehaviour.WRITE_ALWAYS)
@@ -339,7 +339,7 @@ public void updateItemTwice_withoutUuidsOnRequest_thenCreatedUuidPreservedAndLas
339
339
}
340
340
341
341
// ======================================================================
342
- // SCENARIO 1: UpdateItem → UpdateItem
342
+ // SCENARIO 1: PutItem → UpdateItem → UpdateItem
343
343
// Case B: createdUuid provided in request payload (should be ignored)
344
344
// createdUuid stays the same across updates (UpdateBehaviour.WRITE_IF_NOT_EXISTS)
345
345
// lastUpdatedUuid changes on every update (UpdateBehaviour.WRITE_ALWAYS)
@@ -385,7 +385,7 @@ public void putUpdatePut_withoutUuidsOnRequest_thenCreatedUuidPreservedOnUpdateA
385
385
String lastUpdatedUuidAfterFirstPut = afterFirstPut .getLastUpdatedUuid ();
386
386
assertRecordHasValidUuid (afterFirstPut );
387
387
388
- // UPDATE → created preserved, lastUpdated changes
388
+ // UPDATE → createdUuid preserved, lastUpdatedUuid changes
389
389
mappedTable .updateItem (new Record ().id ("id1" ).attribute ("id1" ));
390
390
Record afterUpdate = mappedTable .getItem (r -> r .key (k -> k .partitionValue ("id1" )));
391
391
Assertions .assertThat (afterUpdate .getCreatedUuid ()).isEqualTo (createdUuidAfterFirstPut );
@@ -401,29 +401,29 @@ public void putUpdatePut_withoutUuidsOnRequest_thenCreatedUuidPreservedOnUpdateA
401
401
402
402
// ======================================================================
403
403
// SCENARIO 2: PutItem → UpdateItem → PutItem
404
- // Case B: createdUuid provided on first PUT request → is preserved on UPDATE, regenerated on the next PUT request
405
- // createdUuid stays the same after update, regenerates on PUT (UpdateBehaviour.WRITE_IF_NOT_EXISTS)
406
- // lastUpdatedUuid changes after every request (UpdateBehaviour.WRITE_ALWAYS)
404
+ // Case B: createdUuid provided on first PUT request → is preserved on UPDATE, regenerated on the next PUT request
405
+ // createdUuid stays the same after update, regenerates after PUT (UpdateBehaviour.WRITE_IF_NOT_EXISTS)
406
+ // lastUpdatedUuid changes after every request (UpdateBehaviour.WRITE_ALWAYS)
407
407
// ======================================================================
408
408
@ Test
409
409
public void putUpdatePut_withoutUuidsOnRequest_thenCreatedUuidPreservedOnUpdateAndRegeneratedOnPut_AndLastUpdatedUuidChanged () {
410
410
String manualCreated = "UUID-" + UUID .randomUUID ();
411
411
412
- // First PUT with createdUuid provided in request payload → created preserved, lastUpdated generated
412
+ // First PUT with createdUuid provided in request payload → createdUuid preserved, lastUpdatedUuid generated
413
413
Record first = new Record ().id ("p1" ).attribute ("p1" );
414
414
first .setCreatedUuid (manualCreated );
415
415
mappedTable .putItem (first );
416
416
Record afterFirstPut = mappedTable .getItem (r -> r .key (k -> k .partitionValue ("p1" )));
417
417
Assertions .assertThat (afterFirstPut .getCreatedUuid ()).isEqualTo (manualCreated );
418
418
String lastUpdatedUuidAfterFirstPut = afterFirstPut .getLastUpdatedUuid ();
419
419
420
- // UPDATE → created preserved, lastUpdated changes
420
+ // UPDATE → createdUuid preserved, lastUpdatedUuid changes
421
421
mappedTable .updateItem (new Record ().id ("p1" ).attribute ("id1" ));
422
422
Record afterUpdate = mappedTable .getItem (r -> r .key (k -> k .partitionValue ("p1" )));
423
423
Assertions .assertThat (afterUpdate .getCreatedUuid ()).isEqualTo (manualCreated );
424
424
Assertions .assertThat (afterUpdate .getLastUpdatedUuid ()).isNotEqualTo (lastUpdatedUuidAfterFirstPut );
425
425
426
- // Second PUT without manual createdUuid → both regenerated
426
+ // Second PUT without manual createdUuid → both uuids regenerated
427
427
mappedTable .putItem (new Record ().id ("p1" ).attribute ("p1" ));
428
428
Record afterSecondPut = mappedTable .getItem (r -> r .key (k -> k .partitionValue ("p1" )));
429
429
Assertions .assertThat (afterSecondPut .getCreatedUuid ()).isNotEqualTo (manualCreated );
@@ -434,8 +434,8 @@ public void putUpdatePut_withoutUuidsOnRequest_thenCreatedUuidPreservedOnUpdateA
434
434
// ======================================================================
435
435
// SCENARIO 3: transactWriteItems.addPutItem → addPutItem
436
436
// Case A: UUIDs not provided in request payload (both regenerated on each PUT)
437
- // createdUuid changes after every update (UpdateBehaviour.WRITE_IF_NOT_EXISTS)
438
- // lastUpdatedUuid changes after every update (UpdateBehaviour.WRITE_ALWAYS)
437
+ // createdUuid changes after every update (UpdateBehaviour.WRITE_IF_NOT_EXISTS)
438
+ // lastUpdatedUuid changes after every update (UpdateBehaviour.WRITE_ALWAYS)
439
439
// ======================================================================
440
440
@ Test
441
441
public void transactPutThenPut_withoutUuidsOnRequest_thenBothUuidsRegeneratedEachTime () {
@@ -470,7 +470,7 @@ public void transactPutThenPut_withoutUuidsOnRequest_thenBothUuidsRegeneratedEac
470
470
// lastUpdatedUuid changes after every put (UpdateBehaviour.WRITE_ALWAYS)
471
471
// ======================================================================
472
472
@ Test
473
- public void transactPutWithManualCreatedUuid_thenPutWithoutUuid_thenBothUuidsRegeneratedEachTime () {
473
+ public void transactPutWithManualCreatedUuid_thenPutWithoutUuid_thenBothUuidsRegeneratedOnSecondPut () {
474
474
DynamoDbEnhancedClient client = DynamoDbEnhancedClient .builder ()
475
475
.dynamoDbClient (getDynamoDbClient ())
476
476
.extensions (AutoGeneratedUuidExtension .create ())
@@ -489,9 +489,7 @@ public void transactPutWithManualCreatedUuid_thenPutWithoutUuid_thenBothUuidsReg
489
489
String lastUpdatedUuidAfterFirstUpdateRecord = afterFirstUpdateRecord .getLastUpdatedUuid ();
490
490
491
491
// Transaction PUT #2 without uuids provided in request payload → both regenerated
492
- client .transactWriteItems (TransactWriteItemsEnhancedRequest .builder ()
493
- .addPutItem (table , new Record ().id ("id2" ).attribute ("p2" ))
494
- .build ());
492
+ table .putItem (new Record ().id ("id2" ).attribute ("p2" ));
495
493
Record afterSecondUpdateRecord = table .getItem (r -> r .key (k -> k .partitionValue ("id2" )));
496
494
Assertions .assertThat (afterSecondUpdateRecord .getCreatedUuid ()).isNotEqualTo (manualCreated );
497
495
Assertions .assertThat (afterSecondUpdateRecord .getLastUpdatedUuid ()).isNotEqualTo (lastUpdatedUuidAfterFirstUpdateRecord );
0 commit comments