From df37a55a4c73d21d7c4f43c923275d329c439256 Mon Sep 17 00:00:00 2001 From: Krishnan Date: Thu, 30 May 2024 04:57:59 -0700 Subject: [PATCH 01/37] Fixed EnhancedClient UpdateItem operation to make it work on nested attributes as well --- .../awssdk/enhanced/dynamodb/TableSchema.java | 2 + .../document/DocumentTableSchema.java | 5 ++ .../internal/EnhancedClientUtils.java | 20 ++++++- .../internal/mapper/MetaTableSchema.java | 5 ++ .../operations/UpdateItemOperation.java | 2 +- .../update/UpdateExpressionUtils.java | 23 ++++++-- .../mapper/StaticImmutableTableSchema.java | 35 +++++++++++++ .../dynamodb/mapper/WrappedTableSchema.java | 5 ++ .../functionaltests/UpdateBehaviorTest.java | 52 +++++++++++++++---- 9 files changed, 131 insertions(+), 18 deletions(-) diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java index 2aa9d100d2c2..6418d12e62f8 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java @@ -244,6 +244,8 @@ default T mapToItem(Map attributeMap, boolean preserveEm */ Map itemToMap(T item, boolean ignoreNulls); + Map updateItemToMap(T item, boolean ignoreNulls); + /** * Takes a modelled object and extracts a specific set of attributes which are then returned as a map of * {@link AttributeValue} that the DynamoDb low-level SDK can work with. This method is typically used to extract diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java index 17b54da8cffd..d1926c1de05b 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java @@ -113,6 +113,11 @@ public Map itemToMap(EnhancedDocument item, boolean igno return item.toBuilder().attributeConverterProviders(providers).build().toMap(); } + @Override + public Map updateItemToMap(EnhancedDocument item, boolean ignoreNulls) { + return itemToMap(item, ignoreNulls); + } + private List mergeAttributeConverterProviders(EnhancedDocument item) { if (item.attributeConverterProviders() != null && !item.attributeConverterProviders().isEmpty()) { Set providers = new LinkedHashSet<>(); diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java index afd719d5a82a..9a19753784a3 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java @@ -15,6 +15,8 @@ package software.amazon.awssdk.enhanced.dynamodb.internal; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema.NESTED_OBJECT_UPDATE; + import java.util.Collections; import java.util.List; import java.util.Map; @@ -22,6 +24,7 @@ import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; import software.amazon.awssdk.annotations.SdkInternalApi; @@ -40,6 +43,7 @@ public final class EnhancedClientUtils { private static final Set SPECIAL_CHARACTERS = Stream.of( '*', '.', '-', '#', '+', ':', '/', '(', ')', ' ', '&', '<', '>', '?', '=', '!', '@', '%', '$', '|').collect(Collectors.toSet()); + private static final Pattern PATTERN = Pattern.compile(NESTED_OBJECT_UPDATE); private EnhancedClientUtils() { @@ -67,18 +71,30 @@ public static String cleanAttributeName(String key) { return somethingChanged ? new String(chars) : key; } + private static boolean isNestedAttribute(String key) { + return key.contains(NESTED_OBJECT_UPDATE); + } + /** * Creates a key token to be used with an ExpressionNames map. */ public static String keyRef(String key) { - return "#AMZN_MAPPED_" + cleanAttributeName(key); + String cleanAttributeName = cleanAttributeName(key); + cleanAttributeName = isNestedAttribute(cleanAttributeName) ? + PATTERN.matcher(cleanAttributeName).replaceAll(".#AMZN_MAPPED_") + : cleanAttributeName; + return "#AMZN_MAPPED_" + cleanAttributeName; } /** * Creates a value token to be used with an ExpressionValues map. */ public static String valueRef(String value) { - return ":AMZN_MAPPED_" + cleanAttributeName(value); + String cleanAttributeName = cleanAttributeName(value); + cleanAttributeName = isNestedAttribute(cleanAttributeName) ? + PATTERN.matcher(cleanAttributeName).replaceAll("_") + : cleanAttributeName; + return ":AMZN_MAPPED_" + cleanAttributeName; } public static T readAndTransformSingleItem(Map itemMap, diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java index 0fba0dc1620d..39c6b9d24d66 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java @@ -54,6 +54,11 @@ public Map itemToMap(T item, boolean ignoreNulls) { return concreteTableSchema().itemToMap(item, ignoreNulls); } + @Override + public Map updateItemToMap(T item, boolean ignoreNulls) { + return concreteTableSchema().updateItemToMap(item, ignoreNulls); + } + @Override public Map itemToMap(T item, Collection attributes) { return concreteTableSchema().itemToMap(item, attributes); diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java index 4b42b69a6443..15743e416cb2 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java @@ -90,7 +90,7 @@ public UpdateItemRequest generateRequest(TableSchema tableSchema, r -> Optional.ofNullable(r.ignoreNulls())) .orElse(null); - Map itemMap = tableSchema.itemToMap(item, Boolean.TRUE.equals(ignoreNulls)); + Map itemMap = tableSchema.updateItemToMap(item, Boolean.TRUE.equals(ignoreNulls)); TableMetadata tableMetadata = tableSchema.tableMetadata(); WriteModification transformation = diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java index 41991e0e2865..bdb54e6c2f5e 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java @@ -18,13 +18,16 @@ import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.isNullAttributeValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.keyRef; import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.valueRef; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema.NESTED_OBJECT_UPDATE; import static software.amazon.awssdk.utils.CollectionUtils.filterMap; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; +import java.util.regex.Pattern; import java.util.stream.Collectors; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; @@ -39,6 +42,8 @@ @SdkInternalApi public final class UpdateExpressionUtils { + private static final Pattern PATTERN = Pattern.compile(NESTED_OBJECT_UPDATE); + private UpdateExpressionUtils() { } @@ -99,7 +104,7 @@ private static List removeActionsFor(Map a private static RemoveAction remove(String attributeName) { return RemoveAction.builder() .path(keyRef(attributeName)) - .expressionNames(Collections.singletonMap(keyRef(attributeName), attributeName)) + .expressionNames(expressionNamesFor(attributeName)) .build(); } @@ -137,8 +142,18 @@ private static Function behaviorBasedValue(UpdateBehavior update * Simple utility method that can create an ExpressionNames map based on a list of attribute names. */ private static Map expressionNamesFor(String... attributeNames) { - return Arrays.stream(attributeNames) - .collect(Collectors.toMap(EnhancedClientUtils::keyRef, Function.identity())); + Map map = new HashMap<>(); + for (String attributeName : attributeNames) { + if (attributeName.contains(NESTED_OBJECT_UPDATE)) { + for (String attribute : PATTERN.split(attributeName)) { + map.put(keyRef(attribute), attribute); + } + } + } + if (map.isEmpty()) { + return Arrays.stream(attributeNames) + .collect(Collectors.toMap(EnhancedClientUtils::keyRef, Function.identity())); + } + return map; } - } \ No newline at end of file diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java index ea86ac9fcec4..235d95f13f39 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java @@ -78,6 +78,7 @@ @SdkPublicApi @ThreadSafe public final class StaticImmutableTableSchema implements TableSchema { + public static final String NESTED_OBJECT_UPDATE = "_NESTED_OBJECT_UPDATE_"; private final List> attributeMappers; private final Supplier newBuilderSupplier; private final Function buildItemFunction; @@ -529,6 +530,40 @@ public Map itemToMap(T item, boolean ignoreNulls) { return unmodifiableMap(attributeValueMap); } + @Override + public Map updateItemToMap(T item, boolean ignoreNulls) { + Map attributeValueMap = new HashMap<>(); + + attributeMappers.forEach(attributeMapper -> { + String attributeKey = attributeMapper.attributeName(); + AttributeValue attributeValue = attributeMapper.attributeGetterMethod().apply(item); + + if (!ignoreNulls || !isNullAttributeValue(attributeValue)) { + if (attributeValue.hasM()) { + nestedUpdateAttributeMapper(attributeValueMap, attributeValue.m(), attributeKey, ignoreNulls); + } else { + attributeValueMap.put(attributeKey, attributeValue); + } + } + }); + + indexedFlattenedMappers.forEach((name, flattenedMapper) -> { + attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls)); + }); + + return unmodifiableMap(attributeValueMap); + } + + public void nestedUpdateAttributeMapper(Map attributeValueMap, + Map updateItemAttributeMap, String attributeKey, + boolean ignoreNulls) { + updateItemAttributeMap.forEach((mapKey, mapValue) -> { + if (!ignoreNulls || !isNullAttributeValue(mapValue)) { + attributeValueMap.put(attributeKey + NESTED_OBJECT_UPDATE + mapKey, mapValue); + } + }); + } + @Override public Map itemToMap(T item, Collection attributes) { Map attributeValueMap = new HashMap<>(); diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java index 2b4e40c70fdb..65c2580215db 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java @@ -67,6 +67,11 @@ public Map itemToMap(T item, boolean ignoreNulls) { return this.delegateTableSchema.itemToMap(item, ignoreNulls); } + @Override + public Map updateItemToMap(T item, boolean ignoreNulls) { + return this.delegateTableSchema.updateItemToMap(item, ignoreNulls); + } + @Override public Map itemToMap(T item, Collection attributes) { return this.delegateTableSchema.itemToMap(item, attributes); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java index fdbe05fb87ee..06c564c896dc 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java @@ -1,10 +1,12 @@ package software.amazon.awssdk.enhanced.dynamodb.functionaltests; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.time.Instant; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.xml.bind.ValidationException; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -15,6 +17,7 @@ import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.NestedRecordWithUpdateBehavior; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecordWithUpdateBehaviors; import software.amazon.awssdk.enhanced.dynamodb.internal.client.ExtensionResolver; +import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; public class UpdateBehaviorTest extends LocalDynamoDbSyncTestBase { private static final Instant INSTANT_1 = Instant.parse("2020-05-03T10:00:00Z"); @@ -145,11 +148,45 @@ public void updateBehaviors_transactWriteItems_secondUpdate() { assertThat(persistedRecord.getCreatedAutoUpdateOn()).isEqualTo(firstUpdatedRecord.getCreatedAutoUpdateOn()); } + @Test + public void updateBehaviors_nested() { + + NestedRecordWithUpdateBehavior nestedRecord = new NestedRecordWithUpdateBehavior(); + nestedRecord.setId("id456"); + nestedRecord.setNestedCounter(5L); + nestedRecord.setNestedUpdateBehaviorAttribute("TEST_BEHAVIOUR_ATTRIBUTE"); + nestedRecord.setNestedTimeAttribute(INSTANT_1); + + RecordWithUpdateBehaviors record = new RecordWithUpdateBehaviors(); + record.setId("id123"); + record.setNestedRecord(nestedRecord); + + mappedTable.putItem(record); + + NestedRecordWithUpdateBehavior updatedNestedRecord = new NestedRecordWithUpdateBehavior(); + updatedNestedRecord.setNestedCounter(10L); + + RecordWithUpdateBehaviors update_record = new RecordWithUpdateBehaviors(); + update_record.setId("id123"); + update_record.setVersion(1L); + update_record.setNestedRecord(updatedNestedRecord); + + mappedTable.updateItem(r -> r.item(update_record).ignoreNulls(true)); + + RecordWithUpdateBehaviors persistedRecord = mappedTable.getItem(r -> r.key(k -> k.partitionValue("id123"))); + + assertThat(persistedRecord.getVersion()).isEqualTo(2L); + assertThat(persistedRecord.getNestedRecord()).isNotNull(); + assertThat(persistedRecord.getNestedRecord().getNestedCounter()).isEqualTo(10L); + assertThat(persistedRecord.getNestedRecord().getNestedUpdateBehaviorAttribute()).isEqualTo("TEST_BEHAVIOUR_ATTRIBUTE"); + assertThat(persistedRecord.getNestedRecord().getNestedTimeAttribute()).isEqualTo(INSTANT_1); + } + /** * Currently, nested records are not updated through extensions. */ @Test - public void updateBehaviors_nested() { + public void updateNonexistentField_nested() { NestedRecordWithUpdateBehavior nestedRecord = new NestedRecordWithUpdateBehavior(); nestedRecord.setId("id456"); @@ -158,15 +195,8 @@ public void updateBehaviors_nested() { record.setCreatedOn(INSTANT_1); record.setLastUpdatedOn(INSTANT_2); record.setNestedRecord(nestedRecord); - mappedTable.updateItem(record); - - RecordWithUpdateBehaviors persistedRecord = mappedTable.getItem(record); - - assertThat(persistedRecord.getVersion()).isEqualTo(1L); - assertThat(persistedRecord.getNestedRecord()).isNotNull(); - assertThat(persistedRecord.getNestedRecord().getNestedVersionedAttribute()).isNull(); - assertThat(persistedRecord.getNestedRecord().getNestedCounter()).isNull(); - assertThat(persistedRecord.getNestedRecord().getNestedUpdateBehaviorAttribute()).isNull(); - assertThat(persistedRecord.getNestedRecord().getNestedTimeAttribute()).isNull(); + assertThatThrownBy(() ->mappedTable.updateItem(record)) + .isInstanceOf(DynamoDbException.class) + .hasMessageContaining("The document path provided in the update expression is invalid for update"); } } From 8c39b17bf9dd7d2540abb1787068d47c0af18aac Mon Sep 17 00:00:00 2001 From: Krishnan Date: Thu, 30 May 2024 12:49:54 -0700 Subject: [PATCH 02/37] Add Tests for multi-level nesting updates to work correctly --- .../mapper/StaticImmutableTableSchema.java | 7 ++- .../functionaltests/UpdateBehaviorTest.java | 45 +++++++++++++++++++ .../NestedRecordWithUpdateBehavior.java | 9 ++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java index 235d95f13f39..b653e8e4afdb 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java @@ -559,7 +559,12 @@ public void nestedUpdateAttributeMapper(Map attributeVal boolean ignoreNulls) { updateItemAttributeMap.forEach((mapKey, mapValue) -> { if (!ignoreNulls || !isNullAttributeValue(mapValue)) { - attributeValueMap.put(attributeKey + NESTED_OBJECT_UPDATE + mapKey, mapValue); + if (mapValue.hasM()) { + nestedUpdateAttributeMapper(attributeValueMap, mapValue.m(), attributeKey + NESTED_OBJECT_UPDATE + mapKey, + ignoreNulls); + } else { + attributeValueMap.put(attributeKey + NESTED_OBJECT_UPDATE + mapKey, mapValue); + } } }); } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java index 06c564c896dc..734425545aed 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java @@ -182,6 +182,51 @@ public void updateBehaviors_nested() { assertThat(persistedRecord.getNestedRecord().getNestedTimeAttribute()).isEqualTo(INSTANT_1); } + @Test + public void updateBehaviors_multi_level_nested() { + + NestedRecordWithUpdateBehavior nestedRecord1 = new NestedRecordWithUpdateBehavior(); + nestedRecord1.setId("id789"); + nestedRecord1.setNestedCounter(50L); + nestedRecord1.setNestedUpdateBehaviorAttribute("TEST_BEHAVIOUR_ATTRIBUTE"); + nestedRecord1.setNestedTimeAttribute(INSTANT_1); + + NestedRecordWithUpdateBehavior nestedRecord2 = new NestedRecordWithUpdateBehavior(); + nestedRecord2.setId("id456"); + nestedRecord2.setNestedCounter(5L); + nestedRecord2.setNestedUpdateBehaviorAttribute("TEST_BEHAVIOUR_ATTRIBUTE"); + nestedRecord2.setNestedTimeAttribute(INSTANT_1); + nestedRecord2.setNestedRecord(nestedRecord1); + + RecordWithUpdateBehaviors record = new RecordWithUpdateBehaviors(); + record.setId("id123"); + record.setNestedRecord(nestedRecord2); + + mappedTable.putItem(record); + + NestedRecordWithUpdateBehavior updatedNestedRecord2 = new NestedRecordWithUpdateBehavior(); + updatedNestedRecord2.setNestedCounter(100L); + + NestedRecordWithUpdateBehavior updatedNestedRecord1 = new NestedRecordWithUpdateBehavior(); + updatedNestedRecord1.setNestedRecord(updatedNestedRecord2); + + RecordWithUpdateBehaviors update_record = new RecordWithUpdateBehaviors(); + update_record.setId("id123"); + update_record.setVersion(1L); + update_record.setNestedRecord(updatedNestedRecord1); + + mappedTable.updateItem(r -> r.item(update_record).ignoreNulls(true)); + + RecordWithUpdateBehaviors persistedRecord = mappedTable.getItem(r -> r.key(k -> k.partitionValue("id123"))); + + assertThat(persistedRecord.getVersion()).isEqualTo(2L); + assertThat(persistedRecord.getNestedRecord()).isNotNull(); + assertThat(persistedRecord.getNestedRecord().getNestedRecord()).isNotNull(); + assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedCounter()).isEqualTo(100L); + //assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedUpdateBehaviorAttribute()).isEqualTo("TEST_BEHAVIOUR_ATTRIBUTE"); + assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedTimeAttribute()).isEqualTo(INSTANT_1); + } + /** * Currently, nested records are not updated through extensions. */ diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/NestedRecordWithUpdateBehavior.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/NestedRecordWithUpdateBehavior.java index 9e31533d97bd..32811355a803 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/NestedRecordWithUpdateBehavior.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/NestedRecordWithUpdateBehavior.java @@ -32,6 +32,7 @@ public class NestedRecordWithUpdateBehavior { private Long nestedVersionedAttribute; private Instant nestedTimeAttribute; private Long nestedCounter; + private NestedRecordWithUpdateBehavior nestedRecord; @DynamoDbPartitionKey public String getId() { @@ -77,4 +78,12 @@ public Long getNestedCounter() { public void setNestedCounter(Long nestedCounter) { this.nestedCounter = nestedCounter; } + + public NestedRecordWithUpdateBehavior getNestedRecord() { + return nestedRecord; + } + + public void setNestedRecord(NestedRecordWithUpdateBehavior nestedRecord) { + this.nestedRecord = nestedRecord; + } } From 559b7b493459e3ce640b346d92417908247c0b99 Mon Sep 17 00:00:00 2001 From: Krishnan Date: Mon, 1 Jul 2024 07:14:20 -0700 Subject: [PATCH 03/37] Fixed PR feedback --- .../awssdk/enhanced/dynamodb/TableSchema.java | 5 +- .../document/DocumentTableSchema.java | 8 +- .../attribute/DocumentAttributeConverter.java | 4 +- .../internal/mapper/MetaTableSchema.java | 10 +-- .../internal/operations/PutItemOperation.java | 4 +- .../operations/UpdateItemOperation.java | 3 +- .../update/UpdateExpressionUtils.java | 17 ++-- .../dynamodb/mapper/AttributeMapping.java | 21 +++++ .../mapper/StaticImmutableTableSchema.java | 57 +++++-------- .../dynamodb/mapper/WrappedTableSchema.java | 8 +- .../annotations/DynamoDbIgnoreNulls.java | 7 +- .../document/DocumentTableSchemaTest.java | 5 +- .../AtomicCounterExtensionTest.java | 13 +-- .../AutoGeneratedUuidExtensionTest.java | 7 +- .../extensions/ChainExtensionTest.java | 3 +- .../VersionedRecordExtensionTest.java | 23 ++--- .../AutoGeneratedTimestampRecordTest.java | 3 +- .../AutoGeneratedUuidRecordTest.java | 3 +- .../BeanTableSchemaRecursiveTest.java | 5 +- .../ImmutableTableSchemaRecursiveTest.java | 5 +- .../functionaltests/UpdateBehaviorTest.java | 82 +++++++++++------- .../functionaltests/models/FakeItem.java | 13 +++ .../models/FakeItemComposedClass.java | 12 ++- .../internal/DefaultDocumentTest.java | 7 +- .../immutable/MetaTableSchemaTest.java | 14 +-- .../operations/DeleteItemOperationTest.java | 11 +-- .../operations/GetItemOperationTest.java | 5 +- .../operations/PutItemOperationTest.java | 13 +-- .../TransactWriteItemsOperationTest.java | 5 +- .../operations/UpdateItemOperationTest.java | 69 ++++++++++++--- .../UpdateItemOperationTransactTest.java | 7 +- .../dynamodb/mapper/BeanTableSchemaTest.java | 85 ++++++++++--------- .../mapper/ImmutableTableSchemaTest.java | 23 ++--- .../StaticImmutableTableSchemaExtendTest.java | 3 +- ...StaticImmutableTableSchemaFlattenTest.java | 3 +- .../StaticImmutableTableSchemaTest.java | 29 ++++--- .../mapper/StaticTableSchemaTest.java | 24 +++--- .../TransactGetItemsEnhancedRequestTest.java | 3 +- ...TransactWriteItemsEnhancedRequestTest.java | 3 +- 39 files changed, 368 insertions(+), 254 deletions(-) create mode 100644 services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java index 6418d12e62f8..1d3ac9bf4a66 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java @@ -22,6 +22,7 @@ import software.amazon.awssdk.annotations.ThreadSafe; import software.amazon.awssdk.enhanced.dynamodb.document.DocumentTableSchema; import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocument; +import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; import software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.ImmutableTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema; @@ -242,9 +243,7 @@ default T mapToItem(Map attributeMap, boolean preserveEm * type 'nul' to the output map. * @return A map of String to {@link AttributeValue} representing all the modelled attributes in the model object. */ - Map itemToMap(T item, boolean ignoreNulls); - - Map updateItemToMap(T item, boolean ignoreNulls); + Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping); /** * Takes a modelled object and extracts a specific set of attributes which are then returned as a map of diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java index d1926c1de05b..e9773b4cf786 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java @@ -37,6 +37,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.internal.converter.ConverterProviderResolver; import software.amazon.awssdk.enhanced.dynamodb.internal.document.DefaultEnhancedDocument; +import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableMetadata; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -105,7 +106,7 @@ public EnhancedDocument mapToItem(Map attributeMap) { * */ @Override - public Map itemToMap(EnhancedDocument item, boolean ignoreNulls) { + public Map itemToMap(EnhancedDocument item, boolean ignoreNulls, AttributeMapping attributeMapping) { if (item == null) { return null; } @@ -113,11 +114,6 @@ public Map itemToMap(EnhancedDocument item, boolean igno return item.toBuilder().attributeConverterProviders(providers).build().toMap(); } - @Override - public Map updateItemToMap(EnhancedDocument item, boolean ignoreNulls) { - return itemToMap(item, ignoreNulls); - } - private List mergeAttributeConverterProviders(EnhancedDocument item) { if (item.attributeConverterProviders() != null && !item.attributeConverterProviders().isEmpty()) { Set providers = new LinkedHashSet<>(); diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java index 3dc67e1bdc56..73758e494479 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java @@ -15,6 +15,8 @@ package software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; + import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.enhanced.dynamodb.AttributeConverter; import software.amazon.awssdk.enhanced.dynamodb.AttributeValueType; @@ -54,7 +56,7 @@ public static DocumentAttributeConverter create(TableSchema tableSchem @Override public AttributeValue transformFrom(T input) { - return AttributeValue.builder().m(tableSchema.itemToMap(input, ignoreNulls)).build(); + return AttributeValue.builder().m(tableSchema.itemToMap(input, ignoreNulls, SHALLOW)).build(); } @Override diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java index 39c6b9d24d66..a2bc8d466c40 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java @@ -23,6 +23,7 @@ import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; /** @@ -50,13 +51,8 @@ public T mapToItem(Map attributeMap) { } @Override - public Map itemToMap(T item, boolean ignoreNulls) { - return concreteTableSchema().itemToMap(item, ignoreNulls); - } - - @Override - public Map updateItemToMap(T item, boolean ignoreNulls) { - return concreteTableSchema().updateItemToMap(item, ignoreNulls); + public Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { + return concreteTableSchema().itemToMap(item, ignoreNulls, attributeMapping); } @Override diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java index 3e0b8a2cfa62..fb0bf10e157e 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java @@ -15,6 +15,8 @@ package software.amazon.awssdk.enhanced.dynamodb.internal.operations; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; + import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -87,7 +89,7 @@ public PutItemRequest generateRequest(TableSchema tableSchema, boolean alwaysIgnoreNulls = true; T item = request.map(PutItemEnhancedRequest::item, TransactPutItemEnhancedRequest::item); - Map itemMap = tableSchema.itemToMap(item, alwaysIgnoreNulls); + Map itemMap = tableSchema.itemToMap(item, alwaysIgnoreNulls, SHALLOW); WriteModification transformation = extension != null ? extension.beforeWrite( diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java index 98aef59534ac..b366c5c258e4 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java @@ -17,6 +17,7 @@ import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.readAndTransformSingleItem; import static software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionUtils.operationExpression; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; import static software.amazon.awssdk.utils.CollectionUtils.filterMap; import java.util.Collection; @@ -90,7 +91,7 @@ public UpdateItemRequest generateRequest(TableSchema tableSchema, r -> Optional.ofNullable(r.ignoreNulls())) .orElse(null); - Map itemMap = tableSchema.updateItemToMap(item, Boolean.TRUE.equals(ignoreNulls)); + Map itemMap = tableSchema.itemToMap(item, Boolean.TRUE.equals(ignoreNulls), NESTED); TableMetadata tableMetadata = tableSchema.tableMetadata(); WriteModification transformation = diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java index bdb54e6c2f5e..98ae4e189cc4 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionUtils.java @@ -21,7 +21,6 @@ import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema.NESTED_OBJECT_UPDATE; import static software.amazon.awssdk.utils.CollectionUtils.filterMap; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -31,7 +30,6 @@ import java.util.stream.Collectors; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; -import software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.UpdateBehaviorTag; import software.amazon.awssdk.enhanced.dynamodb.mapper.UpdateBehavior; import software.amazon.awssdk.enhanced.dynamodb.update.RemoveAction; @@ -141,18 +139,17 @@ private static Function behaviorBasedValue(UpdateBehavior update /** * Simple utility method that can create an ExpressionNames map based on a list of attribute names. */ - private static Map expressionNamesFor(String... attributeNames) { + private static Map expressionNamesFor(String attributeNames) { Map map = new HashMap<>(); - for (String attributeName : attributeNames) { - if (attributeName.contains(NESTED_OBJECT_UPDATE)) { - for (String attribute : PATTERN.split(attributeName)) { - map.put(keyRef(attribute), attribute); - } + + if (attributeNames.contains(NESTED_OBJECT_UPDATE)) { + for (String attribute : PATTERN.split(attributeNames)) { + map.put(keyRef(attribute), attribute); } } + if (map.isEmpty()) { - return Arrays.stream(attributeNames) - .collect(Collectors.toMap(EnhancedClientUtils::keyRef, Function.identity())); + map.put(keyRef(attributeNames), attributeNames); } return map; } diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java new file mode 100644 index 000000000000..92dfb313535c --- /dev/null +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java @@ -0,0 +1,21 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.enhanced.dynamodb.mapper; + +public enum AttributeMapping { + SHALLOW, + NESTED +} diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java index b653e8e4afdb..1ea84f3d8458 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java @@ -17,6 +17,7 @@ import static java.util.Collections.unmodifiableMap; import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.isNullAttributeValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; import java.util.ArrayList; import java.util.Arrays; @@ -124,14 +125,14 @@ private B mapToItem(B thisBuilder, return thisBuilder; } - private Map itemToMap(T item, boolean ignoreNulls) { + private Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { T1 otherItem = this.otherItemGetter.apply(item); if (otherItem == null) { return Collections.emptyMap(); } - return this.otherItemTableSchema.itemToMap(otherItem, ignoreNulls); + return this.otherItemTableSchema.itemToMap(otherItem, ignoreNulls, attributeMapping); } private AttributeValue attributeValue(T item, String attributeName) { @@ -511,36 +512,16 @@ public T mapToItem(Map attributeMap) { } @Override - public Map itemToMap(T item, boolean ignoreNulls) { + public Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { Map attributeValueMap = new HashMap<>(); attributeMappers.forEach(attributeMapper -> { String attributeKey = attributeMapper.attributeName(); AttributeValue attributeValue = attributeMapper.attributeGetterMethod().apply(item); - if (!ignoreNulls || !isNullAttributeValue(attributeValue)) { - attributeValueMap.put(attributeKey, attributeValue); - } - }); - - indexedFlattenedMappers.forEach((name, flattenedMapper) -> { - attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls)); - }); - - return unmodifiableMap(attributeValueMap); - } - - @Override - public Map updateItemToMap(T item, boolean ignoreNulls) { - Map attributeValueMap = new HashMap<>(); - - attributeMappers.forEach(attributeMapper -> { - String attributeKey = attributeMapper.attributeName(); - AttributeValue attributeValue = attributeMapper.attributeGetterMethod().apply(item); - - if (!ignoreNulls || !isNullAttributeValue(attributeValue)) { - if (attributeValue.hasM()) { - nestedUpdateAttributeMapper(attributeValueMap, attributeValue.m(), attributeKey, ignoreNulls); + if (attributeValueNonNullOrShouldWriteNull(ignoreNulls, attributeValue)) { + if (attributeMapping == NESTED && attributeValue.hasM()) { + nestedItemToMap(attributeValueMap, attributeValue.m(), attributeKey, ignoreNulls); } else { attributeValueMap.put(attributeKey, attributeValue); } @@ -548,22 +529,24 @@ public Map updateItemToMap(T item, boolean ignoreNulls) }); indexedFlattenedMappers.forEach((name, flattenedMapper) -> { - attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls)); + attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls, attributeMapping)); }); return unmodifiableMap(attributeValueMap); } - public void nestedUpdateAttributeMapper(Map attributeValueMap, - Map updateItemAttributeMap, String attributeKey, - boolean ignoreNulls) { - updateItemAttributeMap.forEach((mapKey, mapValue) -> { - if (!ignoreNulls || !isNullAttributeValue(mapValue)) { + private void nestedItemToMap(Map resultAttributeValueMap, + Map updatedItemValuesAttributeMap, + String attributeKey, + boolean ignoreNulls) { + updatedItemValuesAttributeMap.forEach((mapKey, mapValue) -> { + String nestedAttributeKey = attributeKey + NESTED_OBJECT_UPDATE + mapKey; + if (attributeValueNonNullOrShouldWriteNull(ignoreNulls, mapValue)) { if (mapValue.hasM()) { - nestedUpdateAttributeMapper(attributeValueMap, mapValue.m(), attributeKey + NESTED_OBJECT_UPDATE + mapKey, - ignoreNulls); + nestedItemToMap(resultAttributeValueMap, mapValue.m(), nestedAttributeKey, + ignoreNulls); } else { - attributeValueMap.put(attributeKey + NESTED_OBJECT_UPDATE + mapKey, mapValue); + resultAttributeValueMap.put(nestedAttributeKey, mapValue); } } }); @@ -651,4 +634,8 @@ public AttributeConverter converterForAttribute(Object key) { } return null; } + + private boolean attributeValueNonNullOrShouldWriteNull(boolean ignoreNulls, AttributeValue attributeValue) { + return !ignoreNulls || !isNullAttributeValue(attributeValue); + } } diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java index 65c2580215db..086eb000ce08 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java @@ -63,13 +63,9 @@ public T mapToItem(Map attributeMap, boolean preserveEmp } @Override - public Map itemToMap(T item, boolean ignoreNulls) { - return this.delegateTableSchema.itemToMap(item, ignoreNulls); - } + public Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { - @Override - public Map updateItemToMap(T item, boolean ignoreNulls) { - return this.delegateTableSchema.updateItemToMap(item, ignoreNulls); + return this.delegateTableSchema.itemToMap(item, ignoreNulls, attributeMapping); } @Override diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java index 4d5b30fe4c39..51ea54e8d1d0 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java @@ -21,11 +21,12 @@ import java.lang.annotation.Target; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; /** - * Specifies that when calling {@link TableSchema#itemToMap(Object, boolean)}, a separate DynamoDB object that is - * stored in the current object should ignore the attributes with null values. Note that if this annotation is absent, NULL - * attributes will be created. + * Specifies that when calling {@link TableSchema#itemToMap(Object, boolean, AttributeMapping)}, a separate DynamoDB object + * that is stored in the current object should ignore the attributes with null values. Note that if this annotation + * is absent, NULL attributes will be created. * *

* Example using {@link DynamoDbIgnoreNulls}: diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java index 8eede432dd34..5257efaeb8e3 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java @@ -20,6 +20,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import static software.amazon.awssdk.enhanced.dynamodb.AttributeConverterProvider.defaultProvider; import static software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocumentTestData.testDataInstance; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Arrays; import java.util.Collections; @@ -125,7 +126,7 @@ void validate_DocumentTableSchemaItemToMap(TestData testData) { DocumentTableSchema documentTableSchema = DocumentTableSchema.builder().build(); Assertions.assertThat( - documentTableSchema.itemToMap(testData.getEnhancedDocument(), false)).isEqualTo(testData.getDdbItemMap()); + documentTableSchema.itemToMap(testData.getEnhancedDocument(), false, SHALLOW)).isEqualTo(testData.getDdbItemMap()); } @ParameterizedTest @@ -234,6 +235,6 @@ void validate_DocumentTableSchema_WithCustomIntegerAttributeProvider() { CustomAttributeForDocumentConverterProvider.create())) .build(); Assertions.assertThat( - documentTableSchema.itemToMap(numberDocument, true)).isEqualTo(resultMap); + documentTableSchema.itemToMap(numberDocument, true, SHALLOW)).isEqualTo(resultMap); } } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java index 6ee6cf915d74..960c72846533 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.enhanced.dynamodb.extensions; import static org.assertj.core.api.Assertions.assertThat; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.atomicCounter; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; @@ -77,7 +78,7 @@ public void beforeWrite_updateItemOperation_hasCounters_createsUpdateExpression( AtomicCounterItem atomicCounterItem = new AtomicCounterItem(); atomicCounterItem.setId(RECORD_ID); - Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true); + Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); assertThat(items).hasSize(1); WriteModification result = @@ -106,7 +107,7 @@ public void beforeWrite_updateItemOperation_noCounters_noChanges() { item.setId(RECORD_ID); item.setNumberAttribute(4L); - Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true); + Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, SHALLOW); assertThat(items).hasSize(2); WriteModification result = @@ -125,7 +126,7 @@ public void beforeWrite_updateItemOperation_hasCountersInItem_createsUpdateExpre atomicCounterItem.setId(RECORD_ID); atomicCounterItem.setCustomCounter(255L); - Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true); + Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); assertThat(items).hasSize(2); WriteModification result = @@ -153,7 +154,7 @@ public void beforeWrite_putItemOperation_hasCounters_createsItemTransform() { AtomicCounterItem atomicCounterItem = new AtomicCounterItem(); atomicCounterItem.setId(RECORD_ID); - Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true); + Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); assertThat(items).hasSize(1); WriteModification result = @@ -174,7 +175,7 @@ public void beforeWrite_putItemOperation_noCounters_noChanges() { item.setId(RECORD_ID); item.setNumberAttribute(4L); - Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true); + Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, SHALLOW); assertThat(items).hasSize(2); WriteModification result = @@ -192,7 +193,7 @@ public void beforeWrite_putItemOperation_noCounters_noChanges() { public void beforeRead_doesNotTransformObject() { AtomicCounterItem atomicCounterItem = new AtomicCounterItem(); atomicCounterItem.setId(RECORD_ID); - Map fakeItemMap = ITEM_MAPPER.itemToMap(atomicCounterItem, true); + Map fakeItemMap = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); ReadModification result = atomicCounterExtension.afterRead(DefaultDynamoDbExtensionContext diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java index cc69f503d50f..6f910ce0cccb 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java @@ -17,6 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; import java.util.Map; @@ -72,7 +73,7 @@ public void beforeWrite_updateItemOperation_hasUuidInItem_doesNotCreateUpdateExp String uuidAttribute = String.valueOf(UUID.randomUUID()); SimpleItem.setUuidAttribute(uuidAttribute); - Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true); + Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, NESTED); assertThat(items).hasSize(2); WriteModification result = @@ -95,7 +96,7 @@ public void beforeWrite_updateItemOperation_hasNoUuidInItem_doesNotCreatesUpdate ItemWithUuid SimpleItem = new ItemWithUuid(); SimpleItem.setId(RECORD_ID); - Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true); + Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, NESTED); assertThat(items).hasSize(1); WriteModification result = @@ -117,7 +118,7 @@ public void beforeWrite_updateItemOperation_UuidNotPresent_newUuidCreated() { ItemWithUuid item = new ItemWithUuid(); item.setId(RECORD_ID); - Map items = ITEM_WITH_UUID_MAPPER.itemToMap(item, true); + Map items = ITEM_WITH_UUID_MAPPER.itemToMap(item, true, NESTED); assertThat(items).hasSize(1); WriteModification result = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java index f68437774203..71bf07abd49f 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java @@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.isNotNull; import static org.mockito.Mockito.when; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collections; import java.util.HashMap; @@ -76,7 +77,7 @@ public class ChainExtensionTest { private final List> fakeItems = IntStream.range(0, 4) .mapToObj($ -> createUniqueFakeItem()) - .map(fakeItem -> FakeItem.getTableSchema().itemToMap(fakeItem, true)) + .map(fakeItem -> FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) .collect(toList()); @Test diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java index 4f61db7487e9..1c6ae6493967 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java @@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.HashMap; import java.util.Map; @@ -43,7 +44,7 @@ public class VersionedRecordExtensionTest { @Test public void beforeRead_doesNotTransformObject() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); ReadModification result = versionedRecordExtension.afterRead(DefaultDynamoDbExtensionContext @@ -63,7 +64,7 @@ public void beforeWrite_initialVersion_expressionIsCorrect() { versionedRecordExtension.beforeWrite( DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -78,13 +79,13 @@ public void beforeWrite_initialVersion_expressionIsCorrect() { public void beforeWrite_initialVersion_transformedItemIsCorrect() { FakeItem fakeItem = createUniqueFakeItem(); Map fakeItemWithInitialVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("1").build()); WriteModification result = versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -96,10 +97,10 @@ public void beforeWrite_initialVersion_transformedItemIsCorrect() { public void beforeWrite_initialVersionDueToExplicitNull_transformedItemIsCorrect() { FakeItem fakeItem = createUniqueFakeItem(); Map inputMap = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); inputMap.put("version", AttributeValue.builder().nul(true).build()); Map fakeItemWithInitialVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("1").build()); WriteModification result = @@ -120,7 +121,7 @@ public void beforeWrite_existingVersion_expressionIsCorrect() { WriteModification result = versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -138,13 +139,13 @@ public void beforeWrite_existingVersion_transformedItemIsCorrect() { FakeItem fakeItem = createUniqueFakeItem(); fakeItem.setVersion(13); Map fakeItemWithInitialVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("14").build()); WriteModification result = versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -155,7 +156,7 @@ public void beforeWrite_existingVersion_transformedItemIsCorrect() { public void beforeWrite_returnsNoOpModification_ifVersionAttributeNotDefined() { FakeItemWithSort fakeItemWithSort = createUniqueFakeItemWithSort(); Map itemMap = - new HashMap<>(FakeItemWithSort.getTableSchema().itemToMap(fakeItemWithSort, true)); + new HashMap<>(FakeItemWithSort.getTableSchema().itemToMap(fakeItemWithSort, true, SHALLOW)); WriteModification writeModification = versionedRecordExtension.beforeWrite( DefaultDynamoDbExtensionContext.builder() .items(itemMap) @@ -169,7 +170,7 @@ public void beforeWrite_returnsNoOpModification_ifVersionAttributeNotDefined() { public void beforeWrite_throwsIllegalArgumentException_ifVersionAttributeIsWrongType() { FakeItem fakeItem = createUniqueFakeItem(); Map fakeItemWIthBadVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); fakeItemWIthBadVersion.put("version", AttributeValue.builder().s("14").build()); versionedRecordExtension.beforeWrite( diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java index 6b20ecb798ef..5d8ee75c8efb 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java @@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is; import static software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedTimestampRecordExtension.AttributeTags.autoGeneratedTimestampAttribute; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.updateBehavior; @@ -118,7 +119,7 @@ public class AutoGeneratedTimestampRecordTest extends LocalDynamoDbSyncTestBase private final List> fakeItems = IntStream.range(0, 4) .mapToObj($ -> createUniqueFakeItem()) - .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true)) + .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, SHALLOW)) .collect(toList()); private final DynamoDbTable mappedTable; diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java index 12ca834b0f8c..cb2521a14d89 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java @@ -18,6 +18,7 @@ import static java.util.stream.Collectors.toList; import static software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedUuidExtension.AttributeTags.autoGeneratedUuidAttribute; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.updateBehavior; @@ -124,7 +125,7 @@ public AutoGeneratedUuidRecordTest(String testName, TableSchema recordTa private final List> fakeItems = IntStream.range(0, 4) .mapToObj($ -> createUniqueFakeItem()) - .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true)) + .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, SHALLOW)) .collect(toList()); private DynamoDbTable mappedTable; diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java index e2919f9769c3..796f2b89364c 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.enhanced.dynamodb.functionaltests; import static org.assertj.core.api.Assertions.assertThat; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collections; import java.util.Map; @@ -48,7 +49,7 @@ public void recursiveRecord_document() { recursiveRecordBean1.setAttribute(1); recursiveRecordBean1.setRecursiveRecordBean(recursiveRecordBean2); - Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true); + Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true, SHALLOW); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); @@ -77,7 +78,7 @@ public void recursiveRecord_list() { recursiveRecordBean1.setAttribute(1); recursiveRecordBean1.setRecursiveRecordList(Collections.singletonList(recursiveRecordBean2)); - Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true); + Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true, SHALLOW); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java index 532160d99d05..739b205de033 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.enhanced.dynamodb.functionaltests; import static org.assertj.core.api.Assertions.assertThat; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collections; import java.util.Map; @@ -50,7 +51,7 @@ public void recursiveRecord_document() { .setRecursiveRecordImmutable(recursiveRecordImmutable2) .build(); - Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true); + Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true, SHALLOW); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); @@ -83,7 +84,7 @@ public void recursiveRecord_list() { .setRecursiveRecordList(Collections.singletonList(recursiveRecordImmutable2)) .build(); - Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true); + Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true, SHALLOW); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java index 734425545aed..061b55521801 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java @@ -4,6 +4,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.time.Instant; +import java.util.HashMap; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.xml.bind.ValidationException; @@ -14,15 +16,18 @@ import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedTimestampRecordExtension; +import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.NestedRecordWithUpdateBehavior; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecordWithUpdateBehaviors; import software.amazon.awssdk.enhanced.dynamodb.internal.client.ExtensionResolver; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; public class UpdateBehaviorTest extends LocalDynamoDbSyncTestBase { private static final Instant INSTANT_1 = Instant.parse("2020-05-03T10:00:00Z"); private static final Instant INSTANT_2 = Instant.parse("2020-05-03T10:05:00Z"); private static final Instant FAR_FUTURE_INSTANT = Instant.parse("9999-05-03T10:05:00Z"); + private static final String TEST_BEHAVIOUR_ATTRIBUTE = "testBehaviourAttribute"; private static final TableSchema TABLE_SCHEMA = TableSchema.fromClass(RecordWithUpdateBehaviors.class); @@ -149,13 +154,9 @@ public void updateBehaviors_transactWriteItems_secondUpdate() { } @Test - public void updateBehaviors_nested() { + public void when_updatingNestedObjectWithSingleLevel_existingInformationIsPreserved_ignoreNulls() { - NestedRecordWithUpdateBehavior nestedRecord = new NestedRecordWithUpdateBehavior(); - nestedRecord.setId("id456"); - nestedRecord.setNestedCounter(5L); - nestedRecord.setNestedUpdateBehaviorAttribute("TEST_BEHAVIOUR_ATTRIBUTE"); - nestedRecord.setNestedTimeAttribute(INSTANT_1); + NestedRecordWithUpdateBehavior nestedRecord = createNestedWithDefaults("id456", 5L); RecordWithUpdateBehaviors record = new RecordWithUpdateBehaviors(); record.setId("id123"); @@ -164,7 +165,8 @@ public void updateBehaviors_nested() { mappedTable.putItem(record); NestedRecordWithUpdateBehavior updatedNestedRecord = new NestedRecordWithUpdateBehavior(); - updatedNestedRecord.setNestedCounter(10L); + long updatedNestedCounter = 10L; + updatedNestedRecord.setNestedCounter(updatedNestedCounter); RecordWithUpdateBehaviors update_record = new RecordWithUpdateBehaviors(); update_record.setId("id123"); @@ -175,27 +177,47 @@ public void updateBehaviors_nested() { RecordWithUpdateBehaviors persistedRecord = mappedTable.getItem(r -> r.key(k -> k.partitionValue("id123"))); - assertThat(persistedRecord.getVersion()).isEqualTo(2L); + verifySingleLevelNestingTargetedUpdateBehavior(persistedRecord, updatedNestedCounter); + } + + private NestedRecordWithUpdateBehavior createNestedWithDefaults(String id, Long counter) { + NestedRecordWithUpdateBehavior nestedRecordWithDefaults = new NestedRecordWithUpdateBehavior(); + nestedRecordWithDefaults.setId(id); + nestedRecordWithDefaults.setNestedCounter(counter); + nestedRecordWithDefaults.setNestedUpdateBehaviorAttribute(TEST_BEHAVIOUR_ATTRIBUTE); + nestedRecordWithDefaults.setNestedTimeAttribute(INSTANT_1); + + return nestedRecordWithDefaults; + } + + private void verifyMultipleLevelNestingTargetedUpdateBehavior(RecordWithUpdateBehaviors persistedRecord, + long updatedOuterNestedCounter, + long updatedInnerNestedCounter) { assertThat(persistedRecord.getNestedRecord()).isNotNull(); - assertThat(persistedRecord.getNestedRecord().getNestedCounter()).isEqualTo(10L); - assertThat(persistedRecord.getNestedRecord().getNestedUpdateBehaviorAttribute()).isEqualTo("TEST_BEHAVIOUR_ATTRIBUTE"); + assertThat(persistedRecord.getNestedRecord().getNestedRecord()).isNotNull(); + + assertThat(persistedRecord.getNestedRecord().getNestedCounter()).isEqualTo(updatedOuterNestedCounter); + assertThat(persistedRecord.getNestedRecord().getNestedRecord()).isNotNull(); + assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedCounter()).isEqualTo(updatedInnerNestedCounter); + assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedUpdateBehaviorAttribute()).isEqualTo( + TEST_BEHAVIOUR_ATTRIBUTE); + assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedTimeAttribute()).isEqualTo(INSTANT_1); + } + + private void verifySingleLevelNestingTargetedUpdateBehavior(RecordWithUpdateBehaviors persistedRecord, + long updatedNestedCounter) { + assertThat(persistedRecord.getNestedRecord()).isNotNull(); + assertThat(persistedRecord.getNestedRecord().getNestedCounter()).isEqualTo(updatedNestedCounter); + assertThat(persistedRecord.getNestedRecord().getNestedUpdateBehaviorAttribute()).isEqualTo(TEST_BEHAVIOUR_ATTRIBUTE); assertThat(persistedRecord.getNestedRecord().getNestedTimeAttribute()).isEqualTo(INSTANT_1); } @Test - public void updateBehaviors_multi_level_nested() { - - NestedRecordWithUpdateBehavior nestedRecord1 = new NestedRecordWithUpdateBehavior(); - nestedRecord1.setId("id789"); - nestedRecord1.setNestedCounter(50L); - nestedRecord1.setNestedUpdateBehaviorAttribute("TEST_BEHAVIOUR_ATTRIBUTE"); - nestedRecord1.setNestedTimeAttribute(INSTANT_1); - - NestedRecordWithUpdateBehavior nestedRecord2 = new NestedRecordWithUpdateBehavior(); - nestedRecord2.setId("id456"); - nestedRecord2.setNestedCounter(5L); - nestedRecord2.setNestedUpdateBehaviorAttribute("TEST_BEHAVIOUR_ATTRIBUTE"); - nestedRecord2.setNestedTimeAttribute(INSTANT_1); + public void when_updatingNestedObjectWithMultipleLevels_existingInformationIsPreserved() { + + NestedRecordWithUpdateBehavior nestedRecord1 = createNestedWithDefaults("id789", 50L); + + NestedRecordWithUpdateBehavior nestedRecord2 = createNestedWithDefaults("id456", 0L); nestedRecord2.setNestedRecord(nestedRecord1); RecordWithUpdateBehaviors record = new RecordWithUpdateBehaviors(); @@ -205,10 +227,13 @@ public void updateBehaviors_multi_level_nested() { mappedTable.putItem(record); NestedRecordWithUpdateBehavior updatedNestedRecord2 = new NestedRecordWithUpdateBehavior(); - updatedNestedRecord2.setNestedCounter(100L); + long innerNestedCounter = 100L; + updatedNestedRecord2.setNestedCounter(innerNestedCounter); NestedRecordWithUpdateBehavior updatedNestedRecord1 = new NestedRecordWithUpdateBehavior(); updatedNestedRecord1.setNestedRecord(updatedNestedRecord2); + long outerNestedCounter = 200L; + updatedNestedRecord1.setNestedCounter(outerNestedCounter); RecordWithUpdateBehaviors update_record = new RecordWithUpdateBehaviors(); update_record.setId("id123"); @@ -219,12 +244,7 @@ public void updateBehaviors_multi_level_nested() { RecordWithUpdateBehaviors persistedRecord = mappedTable.getItem(r -> r.key(k -> k.partitionValue("id123"))); - assertThat(persistedRecord.getVersion()).isEqualTo(2L); - assertThat(persistedRecord.getNestedRecord()).isNotNull(); - assertThat(persistedRecord.getNestedRecord().getNestedRecord()).isNotNull(); - assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedCounter()).isEqualTo(100L); - //assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedUpdateBehaviorAttribute()).isEqualTo("TEST_BEHAVIOUR_ATTRIBUTE"); - assertThat(persistedRecord.getNestedRecord().getNestedRecord().getNestedTimeAttribute()).isEqualTo(INSTANT_1); + verifyMultipleLevelNestingTargetedUpdateBehavior(persistedRecord, outerNestedCounter, innerNestedCounter); } /** @@ -240,7 +260,7 @@ public void updateNonexistentField_nested() { record.setCreatedOn(INSTANT_1); record.setLastUpdatedOn(INSTANT_2); record.setNestedRecord(nestedRecord); - assertThatThrownBy(() ->mappedTable.updateItem(record)) + assertThatThrownBy(() -> mappedTable.updateItem(record)) .isInstanceOf(DynamoDbException.class) .hasMessageContaining("The document path provided in the update expression is invalid for update"); } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java index 246c0fd2a5e7..3dda50be83fd 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java @@ -73,6 +73,19 @@ public static FakeItem createUniqueFakeItem() { .build(); } + public static FakeItem createUniqueFakeItemWithNestedComposedAttribute() { + return FakeItem.builder() + .id(UUID.randomUUID().toString()) + .composedObject(FakeItemComposedClass.builder(). + nestedComposedAttribute( + FakeItemComposedClass.builder(). + composedAttribute("nested").build() + ) + .build()) + .build(); + + } + public String getId() { return id; } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java index 789d78ba95b8..3eb8683fbc71 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java @@ -29,12 +29,14 @@ public class FakeItemComposedClass { .build(); private String composedAttribute; + private FakeItemComposedClass nestedFakeItemComposedClass; public FakeItemComposedClass() { } - public FakeItemComposedClass(String composedAttribute) { + public FakeItemComposedClass(String composedAttribute, FakeItemComposedClass nestedFakeItemComposedClass) { this.composedAttribute = composedAttribute; + this.nestedFakeItemComposedClass = nestedFakeItemComposedClass; } public static Builder builder() { @@ -68,14 +70,20 @@ public int hashCode() { public static class Builder { private String composedAttribute; + private FakeItemComposedClass nestedFakeItemComposedClass; public Builder composedAttribute(String composedAttribute) { this.composedAttribute = composedAttribute; return this; } + public Builder nestedComposedAttribute(FakeItemComposedClass nestedFakeItemComposedClass) { + this.nestedFakeItemComposedClass = nestedFakeItemComposedClass; + return this; + } + public FakeItemComposedClass build() { - return new FakeItemComposedClass(composedAttribute); + return new FakeItemComposedClass(composedAttribute, nestedFakeItemComposedClass); } } } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java index 6bca798c110e..c5a94d42dadf 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java @@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Map; import org.junit.Test; @@ -61,7 +62,7 @@ private DynamoDbTable createMappedTable(DynamoDbEnhancedClientExtensio @Test public void noExtension_mapsToItem() { FakeItem fakeItem = FakeItem.createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); Document defaultDocument = DefaultDocument.create(fakeItemMap); assertThat(defaultDocument.getItem(createMappedTable(null)), is(fakeItem)); @@ -71,8 +72,8 @@ public void noExtension_mapsToItem() { public void extension_mapsToItem() { FakeItem fakeItem = FakeItem.createUniqueFakeItem(); FakeItem fakeItem2 = FakeItem.createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); - Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true, SHALLOW); when(mockDynamoDbEnhancedClientExtension.afterRead(any(DynamoDbExtensionContext.AfterRead.class))) .thenReturn(ReadModification.builder().transformedItem(fakeItemMap2).build()); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java index 7551c0ad605a..69715edefd86 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java @@ -20,6 +20,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collection; import java.util.Collections; @@ -38,6 +39,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.MetaTableSchema; +import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @RunWith(MockitoJUnitRunner.class) @@ -73,17 +75,17 @@ public void mapToItem_notInitialized() { @Test public void itemToMap_ignoreNulls() { metaTableSchema.initialize(mockTableSchema); - when(mockTableSchema.itemToMap(any(FakeItem.class), any(boolean.class))).thenReturn(fakeMap); + when(mockTableSchema.itemToMap(any(FakeItem.class), any(boolean.class), any(AttributeMapping.class))).thenReturn(fakeMap); - assertThat(metaTableSchema.itemToMap(fakeItem, true)).isSameAs(fakeMap); - verify(mockTableSchema).itemToMap(fakeItem, true); - assertThat(metaTableSchema.itemToMap(fakeItem, false)).isSameAs(fakeMap); - verify(mockTableSchema).itemToMap(fakeItem, false); + assertThat(metaTableSchema.itemToMap(fakeItem, true, SHALLOW)).isSameAs(fakeMap); + verify(mockTableSchema).itemToMap(fakeItem, true, SHALLOW); + assertThat(metaTableSchema.itemToMap(fakeItem, false, SHALLOW)).isSameAs(fakeMap); + verify(mockTableSchema).itemToMap(fakeItem, false, SHALLOW); } @Test public void itemToMap_ignoreNulls_notInitialized() { - assertUninitialized(t -> t.itemToMap(fakeItem, true)); + assertUninitialized(t -> t.itemToMap(fakeItem, true, SHALLOW)); } @Test diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java index c8a2ab5fb7f9..7318adc25289 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java @@ -31,6 +31,7 @@ import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collections; import java.util.HashMap; @@ -426,8 +427,8 @@ public void generateRequest_withExtension_doesNotModifyKey() { public void transformResponse_withExtension_appliesItemModification() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false); + Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, SHALLOW); DeleteItemOperation deleteItemOperation = DeleteItemOperation.create(DeleteItemEnhancedRequest.builder() .key(k -> k.partitionValue(baseFakeItem.getId())) @@ -456,7 +457,7 @@ public void transformResponse_withExtension_appliesItemModification() { @Test public void generateTransactWriteItem_basicRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); DeleteItemOperation deleteItemOperation = spy(DeleteItemOperation.create(DeleteItemEnhancedRequest.builder() .key(k -> k.partitionValue(fakeItem.getId())) @@ -486,7 +487,7 @@ public void generateTransactWriteItem_basicRequest() { @Test public void generateTransactWriteItem_conditionalRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); DeleteItemOperation deleteItemOperation = spy(DeleteItemOperation.create(DeleteItemEnhancedRequest.builder() .key(k -> k.partitionValue(fakeItem.getId())) @@ -526,7 +527,7 @@ public void generateTransactWriteItem_conditionalRequest() { @Test public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); String returnValues = "return-values"; DeleteItemOperation deleteItemOperation = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java index ec213dfe6852..059bd9d567aa 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java @@ -27,6 +27,7 @@ import static org.mockito.Mockito.when; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.HashMap; import java.util.Map; @@ -245,8 +246,8 @@ public void generateRequest_withExtension_doesNotModifyKey() { public void transformResponse_withExtension_appliesItemModification() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false); + Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, SHALLOW); GetItemOperation getItemOperation = GetItemOperation.create(GetItemEnhancedRequest.builder().key(k -> k.partitionValue(baseFakeItem.getId())).build()); GetItemResponse response = GetItemResponse.builder() diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java index 195d94974059..7178c45123e5 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java @@ -28,6 +28,7 @@ import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; import java.util.Collections; import java.util.HashMap; @@ -474,8 +475,8 @@ public void transformResponse_doesNotBlowUp() { public void generateRequest_withExtension_modifiesItemToPut() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) .thenReturn(WriteModification.builder().transformedItem(fakeMap).build()); PutItemOperation putItemOperation = PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class) @@ -500,7 +501,7 @@ public void generateRequest_withExtension_modifiesItemToPut() { public void generateRequest_withExtension_singleCondition() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build(); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) .thenReturn(WriteModification.builder().additionalConditionalExpression(condition).build()); @@ -535,7 +536,7 @@ public void generateRequest_withExtension_noModifications() { @Test public void generateTransactWriteItem_basicRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); PutItemOperation putItemOperation = spy(PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class) .item(fakeItem) .build())); @@ -564,7 +565,7 @@ public void generateTransactWriteItem_basicRequest() { @Test public void generateTransactWriteItem_conditionalRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); PutItemOperation putItemOperation = spy(PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class) .item(fakeItem) .build())); @@ -603,7 +604,7 @@ public void generateTransactWriteItem_conditionalRequest() { @Test public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); String returnValues = "return-values"; PutItemOperation putItemOperation = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java index c4fa48fdc21c..f4eb970600c3 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java @@ -23,6 +23,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Map; import org.junit.Before; @@ -48,8 +49,8 @@ public class TransactWriteItemsOperationTest { private final FakeItem fakeItem1 = FakeItem.createUniqueFakeItem(); private final FakeItem fakeItem2 = FakeItem.createUniqueFakeItem(); - private final Map fakeItemMap1 = FakeItem.getTableSchema().itemToMap(fakeItem1, true); - private final Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true); + private final Map fakeItemMap1 = FakeItem.getTableSchema().itemToMap(fakeItem1, true, SHALLOW); + private final Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true, SHALLOW); @Mock private DynamoDbEnhancedClientExtension mockDynamoDbEnhancedClientExtension; diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java index baaaeeddad6f..d953927ced7c 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java @@ -29,8 +29,11 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; +import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItemWithNestedComposedAttribute; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collections; import java.util.HashMap; @@ -282,8 +285,54 @@ public void generateRequest_withExtension_modifiesKeyPortionOfItem() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false); + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, NESTED); + Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id")); + + when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) + .thenReturn(WriteModification.builder().transformedItem(fakeMap).build()); + + UpdateItemOperation updateItemOperation = + UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(baseFakeItem).build()); + + UpdateItemRequest request = updateItemOperation.generateRequest(FakeItem.getTableSchema(), + PRIMARY_CONTEXT, + mockDynamoDbEnhancedClientExtension); + + assertThat(request.key(), is(keyMap)); + verify(mockDynamoDbEnhancedClientExtension).beforeWrite(extensionContext(baseMap, b -> b.operationName(OperationName.UPDATE_ITEM))); + } + + @Test + public void generateRequest_withExtension_nestedAttributes() { + FakeItem baseFakeItem = createUniqueFakeItemWithNestedComposedAttribute(); + FakeItem fakeItem = createUniqueFakeItemWithNestedComposedAttribute(); + + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, NESTED); + Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id")); + + when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) + .thenReturn(WriteModification.builder().transformedItem(fakeMap).build()); + + UpdateItemOperation updateItemOperation = + UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(baseFakeItem).build()); + + UpdateItemRequest request = updateItemOperation.generateRequest(FakeItem.getTableSchema(), + PRIMARY_CONTEXT, + mockDynamoDbEnhancedClientExtension); + + assertThat(request.key(), is(keyMap)); + verify(mockDynamoDbEnhancedClientExtension).beforeWrite(extensionContext(baseMap, b -> b.operationName(OperationName.UPDATE_ITEM))); + } + + @Test + public void generateRequest_withFlattenedMap_withNestedAttributes() { + FakeItem baseFakeItem = createUniqueFakeItem(); + FakeItem fakeItem = createUniqueFakeItem(); + + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, NESTED); Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id")); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) @@ -303,7 +352,7 @@ public void generateRequest_withExtension_modifiesKeyPortionOfItem() { @Test public void generateRequest_withExtension_transformedItemModifiesUpdateExpression() { FakeItem fakeItem = createUniqueFakeItem(); - Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true)); + Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED)); Map fakeMap = new HashMap<>(baseMap); fakeMap.put("subclass_attribute", AttributeValue.builder().s("1").build()); @@ -328,7 +377,7 @@ public void generateRequest_withExtension_transformedItemModifiesUpdateExpressio public void generateRequest_withExtensions_singleCondition() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build(); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) .thenReturn(WriteModification.builder().additionalConditionalExpression(condition).build()); @@ -370,7 +419,7 @@ public void generateRequest_withExtensions_singleUpdateExpression() { public void generateRequest_withExtensions_conditionAndUpdateExpression() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build(); Map deleteActionMap = singletonMap(":val", AttributeValue.builder().s("s").build()); @@ -498,7 +547,7 @@ public void generateRequest_withExtension_noModifications() { @Test public void generateRequest_withExtension_conditionAndModification() { FakeItem baseFakeItem = createUniqueFakeItem(); - Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(baseFakeItem, true)); + Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED)); Map fakeMap = new HashMap<>(baseMap); fakeMap.put("subclass_attribute", AttributeValue.builder().s("1").build()); @@ -637,8 +686,8 @@ public void generateRequest_withReturnValues_knownValue_generatesCorrectRequest( public void transformResponse_withExtension_returnsCorrectTransformedItem() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); when(mockDynamoDbEnhancedClientExtension.afterRead(any(DynamoDbExtensionContext.AfterRead.class))).thenReturn( ReadModification.builder().transformedItem(fakeMap).build()); @@ -655,7 +704,7 @@ public void transformResponse_withNoOpExtension_returnsCorrectItem() { .thenReturn(ReadModification.builder().build()); FakeItem baseFakeItem = createUniqueFakeItem(); - Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true); + Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED); FakeItem resultItem = transformResponse(baseFakeItem); @@ -752,7 +801,7 @@ private FakeItem transformResponse(FakeItem item) { UpdateItemOperation updateItemOperation = UpdateItemOperation.create(requestFakeItem(item, b -> b.ignoreNulls(true))); - Map itemMap = FakeItem.getTableSchema().itemToMap(item, true); + Map itemMap = FakeItem.getTableSchema().itemToMap(item, true, NESTED); return updateItemOperation.transformResponse(UpdateItemResponse.builder().attributes(itemMap).build(), FakeItem.getTableSchema(), PRIMARY_CONTEXT, diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java index 2c72100138ca..c6417257edb5 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java @@ -23,6 +23,7 @@ import static org.mockito.Mockito.verify; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collections; import java.util.Map; @@ -53,7 +54,7 @@ public class UpdateItemOperationTransactTest { @Test public void generateTransactWriteItem_basicRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); UpdateItemOperation updateItemOperation = spy(UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).build())); OperationContext context = DefaultOperationContext.create(TABLE_NAME, TableMetadata.primaryIndexName()); @@ -89,7 +90,7 @@ public void generateTransactWriteItem_basicRequest() { @Test public void generateTransactWriteItem_conditionalRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); UpdateItemOperation updateItemOperation = spy(UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).build())); OperationContext context = DefaultOperationContext.create(TABLE_NAME, TableMetadata.primaryIndexName()); @@ -128,7 +129,7 @@ public void generateTransactWriteItem_conditionalRequest() { @Test public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); String returnValues = "return-values"; UpdateItemOperation updateItemOperation = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java index 792a1821da91..6f33938306ea 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java @@ -27,6 +27,7 @@ import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -134,7 +135,7 @@ public void dynamoDbIgnore_propertyIsIgnored() { ignoredAttributeBean.setId("id-value"); ignoredAttributeBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false); + Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false, SHALLOW); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -147,7 +148,7 @@ public void transient_propertyIsIgnored() { ignoredAttributeBean.setId("id-value"); ignoredAttributeBean.setInteger2Attribute(123); - Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false); + Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false, SHALLOW); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -163,7 +164,7 @@ public void setterAnnotations_alsoWork() { assertThat(beanTableSchema.tableMetadata().primaryPartitionKey(), is("id")); - Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, false); + Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, false, SHALLOW); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); } @@ -185,7 +186,7 @@ public void dynamoDbFlatten_correctlyFlattensBeanAttributes() { flattenedBeanBean.setAttribute1("one"); flattenedBeanBean.setAbstractBean(abstractBean); - Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, false); + Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, false, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -200,7 +201,7 @@ public void dynamoDbPreserveEmptyObject_shouldInitializeAsEmptyClass() { bean.setInnerBean(innerPreserveEmptyBean); - Map itemMap = beanTableSchema.itemToMap(bean, true); + Map itemMap = beanTableSchema.itemToMap(bean, true, SHALLOW); NestedBean nestedBean = beanTableSchema.mapToItem(itemMap); assertThat(nestedBean.getInnerBean(), is(innerPreserveEmptyBean)); } @@ -213,7 +214,7 @@ public void dynamoDbIgnoreNulls_shouldOmitNulls() { bean.setInnerBean1(new AbstractBean()); bean.setInnerBean2(new AbstractBean()); - Map itemMap = beanTableSchema.itemToMap(bean, true); + Map itemMap = beanTableSchema.itemToMap(bean, true, SHALLOW); AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().m(new HashMap<>()).build(); assertThat(itemMap.size(), is(2)); @@ -229,7 +230,7 @@ public void dynamoDbIgnoreNulls_onList_shouldOmitNulls() { bean.setInnerBeanList1(Collections.singletonList(new AbstractBean())); bean.setInnerBeanList2(Collections.singletonList(new AbstractBean())); - Map itemMap = beanTableSchema.itemToMap(bean, true); + Map itemMap = beanTableSchema.itemToMap(bean, true, SHALLOW); AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().l(l -> l.m(emptyMap())).build(); AttributeValue expectedMapForInnerBean2 = AttributeValue.builder() .l(l -> l.m(singletonMap("attribute2", nullAttributeValue()))) @@ -249,7 +250,7 @@ public void dynamoDbFlatten_correctlyFlattensImmutableAttributes() { flattenedImmutableBean.setAttribute1("one"); flattenedImmutableBean.setAbstractImmutable(abstractImmutable); - Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, false); + Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, false, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -270,7 +271,7 @@ public void documentBean_correctlyMapsBeanAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -297,7 +298,7 @@ public void documentBean_list_correctlyMapsBeanAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -331,7 +332,7 @@ public void documentBean_map_correctlyMapsBeanAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -351,7 +352,7 @@ public void documentBean_correctlyMapsImmutableAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -376,7 +377,7 @@ public void documentBean_list_correctlyMapsImmutableAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -408,7 +409,7 @@ public void documentBean_map_correctlyMapsImmutableAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -429,7 +430,7 @@ public void parameterizedDocumentBean_correctlyMapsAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -456,7 +457,7 @@ public void parameterizedDocumentBean_list_correctlyMapsAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -490,7 +491,7 @@ public void parameterizedDocumentBean_map_correctlyMapsAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -505,7 +506,7 @@ public void extendedBean_correctlyExtendsAttributes() { extendedBean.setAttribute1("one"); extendedBean.setAttribute2("two"); - Map itemMap = beanTableSchema.itemToMap(extendedBean, false); + Map itemMap = beanTableSchema.itemToMap(extendedBean, false, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -523,7 +524,7 @@ public void itemToMap_nullAttribute_ignoreNullsTrue() { SimpleBean simpleBean = new SimpleBean(); simpleBean.setId("id-value"); - Map itemMap = beanTableSchema.itemToMap(simpleBean, true); + Map itemMap = beanTableSchema.itemToMap(simpleBean, true, SHALLOW); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -535,7 +536,7 @@ public void itemToMap_nullAttribute_ignoreNullsFalse() { SimpleBean simpleBean = new SimpleBean(); simpleBean.setId("id-value"); - Map itemMap = beanTableSchema.itemToMap(simpleBean, false); + Map itemMap = beanTableSchema.itemToMap(simpleBean, false, SHALLOW); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -549,7 +550,7 @@ public void itemToMap_nonNullAttribute() { simpleBean.setId("id-value"); simpleBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(simpleBean, false); + Map itemMap = beanTableSchema.itemToMap(simpleBean, false, SHALLOW); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -602,7 +603,7 @@ public void enumBean_singleEnum() { enumBean.setId("id-value"); enumBean.setTestEnum(EnumBean.TestEnum.ONE); - Map itemMap = beanTableSchema.itemToMap(enumBean, true); + Map itemMap = beanTableSchema.itemToMap(enumBean, true, SHALLOW); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -619,7 +620,7 @@ public void enumBean_listEnum() { enumBean.setId("id-value"); enumBean.setTestEnumList(Arrays.asList(EnumBean.TestEnum.ONE, EnumBean.TestEnum.TWO)); - Map itemMap = beanTableSchema.itemToMap(enumBean, true); + Map itemMap = beanTableSchema.itemToMap(enumBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .l(stringValue("ONE"), @@ -640,7 +641,7 @@ public void listBean_stringList() { listBean.setId("id-value"); listBean.setStringList(Arrays.asList("one", "two", "three")); - Map itemMap = beanTableSchema.itemToMap(listBean, true); + Map itemMap = beanTableSchema.itemToMap(listBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .l(stringValue("one"), @@ -663,7 +664,7 @@ public void listBean_stringListList() { listBean.setId("id-value"); listBean.setStringListList(Arrays.asList(Arrays.asList("one", "two"), Arrays.asList("three", "four"))); - Map itemMap = beanTableSchema.itemToMap(listBean, true); + Map itemMap = beanTableSchema.itemToMap(listBean, true, SHALLOW); AttributeValue list1 = AttributeValue.builder().l(stringValue("one"), stringValue("two")).build(); AttributeValue list2 = AttributeValue.builder().l(stringValue("three"), stringValue("four")).build(); @@ -690,7 +691,7 @@ public void setBean_stringSet() { stringSet.add("three"); setBean.setStringSet(stringSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .ss("one", "two", "three") @@ -715,7 +716,7 @@ public void setBean_integerSet() { integerSet.add(3); setBean.setIntegerSet(integerSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -740,7 +741,7 @@ public void setBean_longSet() { longSet.add(3L); setBean.setLongSet(longSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -765,7 +766,7 @@ public void setBean_shortSet() { shortSet.add((short)3); setBean.setShortSet(shortSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -790,7 +791,7 @@ public void setBean_byteSet() { byteSet.add((byte)3); setBean.setByteSet(byteSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -815,7 +816,7 @@ public void setBean_doubleSet() { doubleSet.add(3.3); setBean.setDoubleSet(doubleSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1.1", "2.2", "3.3") @@ -840,7 +841,7 @@ public void setBean_floatSet() { floatSet.add(3.3f); setBean.setFloatSet(floatSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1.1", "2.2", "3.3") @@ -869,7 +870,7 @@ public void setBean_binarySet() { binarySet.add(buffer3); setBean.setBinarySet(binarySet); - Map itemMap = beanTableSchema.itemToMap(setBean, true); + Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder() .bs(buffer1, buffer2, buffer3) @@ -895,7 +896,7 @@ public void mapBean_stringStringMap() { mapBean.setStringMap(testMap); - Map itemMap = beanTableSchema.itemToMap(mapBean, true); + Map itemMap = beanTableSchema.itemToMap(mapBean, true, SHALLOW); Map expectedMap = new HashMap<>(); expectedMap.put("one", stringValue("two")); @@ -924,7 +925,7 @@ public void mapBean_mapWithNullValue() { mapBean.setStringMap(testMap); - Map itemMap = beanTableSchema.itemToMap(mapBean, true); + Map itemMap = beanTableSchema.itemToMap(mapBean, true, SHALLOW); Map expectedMap = new HashMap<>(); expectedMap.put("one", AttributeValues.nullAttributeValue()); @@ -953,7 +954,7 @@ public void mapBean_nestedStringMap() { mapBean.setNestedStringMap(testMap); - Map itemMap = beanTableSchema.itemToMap(mapBean, true); + Map itemMap = beanTableSchema.itemToMap(mapBean, true, SHALLOW); Map expectedMap = new HashMap<>(); expectedMap.put("five", AttributeValue.builder().m(singletonMap("one", stringValue("two"))).build()); @@ -987,7 +988,7 @@ public void commonTypesBean() { commonTypesBean.setFloatAttribute((float) 67.8); commonTypesBean.setBinaryAttribute(binaryLiteral); - Map itemMap = beanTableSchema.itemToMap(commonTypesBean, true); + Map itemMap = beanTableSchema.itemToMap(commonTypesBean, true, SHALLOW); assertThat(itemMap.size(), is(9)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -1018,7 +1019,7 @@ public void primitiveTypesBean() { primitiveTypesBean.setDoubleAttribute(56.7); primitiveTypesBean.setFloatAttribute((float) 67.8); - Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, true); + Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, true, SHALLOW); assertThat(itemMap.size(), is(8)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -1078,7 +1079,7 @@ public void usesCustomAttributeConverter() { converterBean.setIntegerAttribute(123); converterBean.setAttributeItem(attributeItem); - Map itemMap = beanTableSchema.itemToMap(converterBean, false); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -1104,7 +1105,7 @@ public void usesCustomAttributeConverterProvider() { converterBean.setId("id-value"); converterBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(converterBean, false); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value-custom"))); @@ -1124,7 +1125,7 @@ public void usesCustomAttributeConverterProviders() { converterBean.setId("id-value"); converterBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(converterBean, false); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value-custom"))); @@ -1150,7 +1151,7 @@ public void emptyConverterProviderList_correct_whenAttributeConvertersAreSupplie converterBean.setId("id-value"); converterBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(converterBean, false); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value-custom"))); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java index 3e97f4d4b660..cfa8f8340a24 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java @@ -21,6 +21,7 @@ import static org.hamcrest.Matchers.is; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Arrays; import java.util.HashMap; @@ -52,7 +53,7 @@ public void documentImmutable_correctlyMapsBeanAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -82,7 +83,7 @@ public void documentImmutable_list_correctlyMapsBeanAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -118,7 +119,7 @@ public void documentImmutable_map_correctlyMapsBeanAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -139,7 +140,7 @@ public void documentImmutable_correctlyMapsImmutableAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -168,7 +169,7 @@ public void documentImmutable_list_correctlyMapsImmutableAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -202,7 +203,7 @@ public void documentImmutable_map_correctlyMapsImmutableAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -221,7 +222,7 @@ public void dynamoDbFlatten_correctlyFlattensBeanAttributes() { .setAbstractBean(abstractBean) .build(); - Map itemMap = tableSchema.itemToMap(flattenedBeanImmutable, false); + Map itemMap = tableSchema.itemToMap(flattenedBeanImmutable, false, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -239,7 +240,7 @@ public void dynamoDbFlatten_correctlyFlattensImmutableAttributes() { .setAbstractImmutable(abstractImmutable) .build(); - Map itemMap = tableSchema.itemToMap(FlattenedImmutableImmutable, false); + Map itemMap = tableSchema.itemToMap(FlattenedImmutableImmutable, false, SHALLOW); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -257,7 +258,7 @@ public void dynamodbPreserveEmptyObject_shouldInitializeAsEmptyClass() { .innerBean(abstractImmutable) .build(); - Map itemMap = tableSchema.itemToMap(nestedImmutable, false); + Map itemMap = tableSchema.itemToMap(nestedImmutable, false, SHALLOW); assertThat(itemMap.size(), is(3)); NestedImmutable result = tableSchema.mapToItem(itemMap); @@ -275,7 +276,7 @@ public void dynamoDbIgnoreNulls_shouldOmitNulls() { .innerBean2(AbstractImmutable.builder().build()) .build(); - Map itemMap = tableSchema.itemToMap(nestedImmutable, true); + Map itemMap = tableSchema.itemToMap(nestedImmutable, true, SHALLOW); assertThat(itemMap.size(), is(2)); AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().m(new HashMap<>()).build(); @@ -293,7 +294,7 @@ public void toBuilderImmutable_ignoresToBuilderMethod() { .attribute1("one") .build(); - Map itemMap = toBuilderImmutableTableSchema.itemToMap(toBuilderImmutable, true); + Map itemMap = toBuilderImmutableTableSchema.itemToMap(toBuilderImmutable, true, SHALLOW); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java index 818f25cf38f6..964fe91b1359 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.enhanced.dynamodb.mapper; import static org.assertj.core.api.Assertions.assertThat; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; import java.util.Collections; @@ -66,7 +67,7 @@ public class StaticImmutableTableSchemaExtendTest { @Test public void itemToMap() { - Map result = immutableTableSchema.itemToMap(TEST_RECORD, false); + Map result = immutableTableSchema.itemToMap(TEST_RECORD, false, SHALLOW); assertThat(result).isEqualTo(ITEM_MAP); } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java index 117dacd66ac4..b24a2ca619fe 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.enhanced.dynamodb.mapper; import static org.assertj.core.api.Assertions.assertThat; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; import java.util.Arrays; @@ -148,7 +149,7 @@ public class StaticImmutableTableSchemaFlattenTest { @Test public void itemToMap_completeRecord() { - Map result = immutableTableSchema.itemToMap(TEST_RECORD, false); + Map result = immutableTableSchema.itemToMap(TEST_RECORD, false, SHALLOW); assertThat(result).isEqualTo(ITEM_MAP); } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java index 5c1b8b2a4d11..a5572232bffe 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java @@ -30,6 +30,7 @@ import static software.amazon.awssdk.enhanced.dynamodb.extensions.VersionedRecordExtension.AttributeTags.versionAttribute; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; import java.math.BigDecimal; @@ -823,7 +824,7 @@ public void getTableMetadata_hasCorrectFields() { @Test public void itemToMap_returnsCorrectMapWithMultipleAttributes() { - Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false); + Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false, SHALLOW); assertThat(attributeMap.size(), is(3)); assertThat(attributeMap, hasEntry("a_boolean", ATTRIBUTE_VALUE_B)); @@ -834,7 +835,7 @@ public void itemToMap_returnsCorrectMapWithMultipleAttributes() { @Test public void itemToMap_omitsNullAttributes() { FakeMappedItem fakeMappedItemWithNulls = FakeMappedItem.builder().aPrimitiveBoolean(true).build(); - Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true); + Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true, SHALLOW); assertThat(attributeMap.size(), is(1)); assertThat(attributeMap, hasEntry("a_primitive_boolean", ATTRIBUTE_VALUE_B)); @@ -1291,7 +1292,7 @@ public void mapToItem_correctlyConstructsComposedClass() { public void mapToItem_preserveEmptyBean_shouldInitializeEmptyBean() { FakeItem fakeItem = new FakeItem(); - Map itemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false); + Map itemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, SHALLOW); FakeItem result = FakeItem.getTableSchema().mapToItem(itemMap, true); assertThat(result, is(fakeItem)); @@ -1324,7 +1325,7 @@ public void mapToItem_nestedBeanPreserveEmptyBean_shouldInitializeEmptyBean() { FakeItemComposedClass nestedBean = new FakeItemComposedClass(); FakeItem fakeItem = new FakeItem("1", 1, nestedBean); - Map itemMap = staticTableSchema.itemToMap(fakeItem, false); + Map itemMap = staticTableSchema.itemToMap(fakeItem, false, SHALLOW); FakeItem result = staticTableSchema.mapToItem(itemMap); assertThat(result.getComposedObject(), is(nestedBean)); @@ -1349,7 +1350,7 @@ public void itemToMap_nestedBeanIgnoreNulls_shouldOmitNullFields() { FakeItemComposedClass nestedBean = new FakeItemComposedClass(); FakeItem fakeItem = new FakeItem("1", 1, nestedBean); - Map itemMap = staticTableSchema.itemToMap(fakeItem, true); + Map itemMap = staticTableSchema.itemToMap(fakeItem, true, SHALLOW); AttributeValue expectedAttributeValue = AttributeValue.builder().m(new HashMap<>()).build(); assertThat(itemMap.size(), is(2)); System.out.println(itemMap); @@ -1365,7 +1366,7 @@ public void buildAbstractTableSchema() { .setter(FakeMappedItem::setAString)) .build(); - assertThat(tableSchema.itemToMap(FAKE_ITEM, false), is(singletonMap("aString", stringValue("test-string")))); + assertThat(tableSchema.itemToMap(FAKE_ITEM, false, SHALLOW), is(singletonMap("aString", stringValue("test-string")))); exception.expect(UnsupportedOperationException.class); exception.expectMessage("abstract"); @@ -1384,7 +1385,7 @@ public void buildAbstractWithFlatten() { FakeDocument document = FakeDocument.of("test-string", null); FakeMappedItem item = FakeMappedItem.builder().aFakeDocument(document).build(); - assertThat(tableSchema.itemToMap(item, true), + assertThat(tableSchema.itemToMap(item, true, SHALLOW), is(singletonMap("documentString", AttributeValue.builder().s("test-string").build()))); } @@ -1405,7 +1406,7 @@ public void buildAbstractExtends() { FakeAbstractSubclass item = new FakeAbstractSubclass(); item.setAString("test-string"); - assertThat(subclassTableSchema.itemToMap(item, true), + assertThat(subclassTableSchema.itemToMap(item, true, SHALLOW), is(singletonMap("aString", AttributeValue.builder().s("test-string").build()))); } @@ -1488,7 +1489,7 @@ public void usesCustomAttributeConverterProvider() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1510,7 +1511,7 @@ public void usesCustomAttributeConverterProviders() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1546,7 +1547,7 @@ public void noConverterProvider_handlesCorrectly_whenAttributeConvertersAreSuppl .build(); Map resultMap = tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), - false); + false, SHALLOW); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1567,7 +1568,7 @@ public void builder_canBuildForGenericClassType() { Map expectedMap = Collections.singletonMap("entity", AttributeValue.fromS("test-value")); - assertThat(envelopeTableSchema.itemToMap(testEnvelope, false), equalTo(expectedMap)); + assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, SHALLOW), equalTo(expectedMap)); assertThat(envelopeTableSchema.mapToItem(expectedMap).entity(), equalTo("test-value")); } @@ -1582,7 +1583,7 @@ private void verifyAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", attributeValue); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); @@ -1599,7 +1600,7 @@ private void verifyNullAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", nullAttributeValue()); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java index 368ef26b9648..7bba9ad87af5 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java @@ -29,6 +29,8 @@ import static org.mockito.Mockito.when; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.math.BigDecimal; import java.util.Arrays; @@ -820,7 +822,7 @@ public void getTableMetadata_hasCorrectFields() { @Test public void itemToMap_returnsCorrectMapWithMultipleAttributes() { - Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false); + Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false, SHALLOW); assertThat(attributeMap.size(), is(3)); assertThat(attributeMap, hasEntry("a_boolean", ATTRIBUTE_VALUE_B)); @@ -831,7 +833,7 @@ public void itemToMap_returnsCorrectMapWithMultipleAttributes() { @Test public void itemToMap_omitsNullAttributes() { FakeMappedItem fakeMappedItemWithNulls = FakeMappedItem.builder().aPrimitiveBoolean(true).build(); - Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true); + Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true, SHALLOW); assertThat(attributeMap.size(), is(1)); assertThat(attributeMap, hasEntry("a_primitive_boolean", ATTRIBUTE_VALUE_B)); @@ -1311,7 +1313,7 @@ public void buildAbstractTableSchema() { .setter(FakeMappedItem::setAString)) .build(); - assertThat(tableSchema.itemToMap(FAKE_ITEM, false), is(singletonMap("aString", stringValue("test-string")))); + assertThat(tableSchema.itemToMap(FAKE_ITEM, false, SHALLOW), is(singletonMap("aString", stringValue("test-string")))); exception.expect(UnsupportedOperationException.class); exception.expectMessage("abstract"); @@ -1330,7 +1332,7 @@ public void buildAbstractWithFlatten() { FakeDocument document = FakeDocument.of("test-string", null); FakeMappedItem item = FakeMappedItem.builder().aFakeDocument(document).build(); - assertThat(tableSchema.itemToMap(item, true), + assertThat(tableSchema.itemToMap(item, true, SHALLOW), is(singletonMap("documentString", AttributeValue.builder().s("test-string").build()))); } @@ -1351,7 +1353,7 @@ public void buildAbstractExtends() { FakeAbstractSubclass item = new FakeAbstractSubclass(); item.setAString("test-string"); - assertThat(subclassTableSchema.itemToMap(item, true), + assertThat(subclassTableSchema.itemToMap(item, true, SHALLOW), is(singletonMap("aString", AttributeValue.builder().s("test-string").build()))); } @@ -1434,7 +1436,7 @@ public void usesCustomAttributeConverterProvider() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1456,7 +1458,7 @@ public void usesCustomAttributeConverterProviders() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1492,7 +1494,7 @@ public void noConverterProvider_handlesCorrectly_whenAttributeConvertersAreSuppl .build(); Map resultMap = tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), - false); + false, SHALLOW); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1513,7 +1515,7 @@ public void builder_canBuildForGenericClassType() { Map expectedMap = Collections.singletonMap("entity", AttributeValue.fromS("test-value")); - assertThat(envelopeTableSchema.itemToMap(testEnvelope, false), equalTo(expectedMap)); + assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, SHALLOW), equalTo(expectedMap)); assertThat(envelopeTableSchema.mapToItem(expectedMap).getEntity(), equalTo("test-value")); } @@ -1528,7 +1530,7 @@ private void verifyAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", attributeValue); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); @@ -1545,7 +1547,7 @@ private void verifyNullAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", nullAttributeValue()); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java index d3ad194e64ae..cb77755af1de 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java @@ -19,6 +19,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; import java.util.Arrays; import java.util.List; @@ -94,7 +95,7 @@ public void builder_maximal_builder_style() { private List getTransactGetItems(FakeItem fakeItem) { - final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); TransactGetItem getItem = TransactGetItem.builder() .get(Get.builder() diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java index c17becfe54bd..4b707eecb714 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Arrays; import java.util.List; @@ -185,7 +186,7 @@ public void builder_passRequestToken_shouldWork() { } private List getTransactWriteItems(FakeItem fakeItem) { - final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true); + final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); TransactWriteItem putWriteItem = TransactWriteItem.builder() .put(Put.builder() From f677cfde08bfa520e91bb27ddf18050cbc7b704c Mon Sep 17 00:00:00 2001 From: Krishnan Date: Mon, 1 Jul 2024 07:38:03 -0700 Subject: [PATCH 04/37] Updated Javadocs --- .../software/amazon/awssdk/enhanced/dynamodb/TableSchema.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java index 1d3ac9bf4a66..91b9624f52c2 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java @@ -241,6 +241,8 @@ default T mapToItem(Map attributeMap, boolean preserveEm * @param ignoreNulls If set to true; any null values in the Java object will not be added to the output map. * If set to false; null values in the Java object will be added as {@link AttributeValue} of * type 'nul' to the output map. + * @param attributeMapping denotes the level of nesting, i.e. SHALLOW or NESTED, contained in the request params based + * which nested update query parameters would be dealt with * @return A map of String to {@link AttributeValue} representing all the modelled attributes in the model object. */ Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping); From cf96d13599e9b06fe339dd37adaa734092ddde4d Mon Sep 17 00:00:00 2001 From: Krishnan Date: Tue, 2 Jul 2024 00:09:10 -0700 Subject: [PATCH 05/37] Addressed Pr feedback --- .../awssdk/enhanced/dynamodb/TableSchema.java | 20 ++- .../document/DocumentTableSchema.java | 12 +- .../DynamoDBEnhancedRequestConfiguration.java | 36 +++++ .../attribute/DocumentAttributeConverter.java | 4 +- .../internal/mapper/MetaTableSchema.java | 11 +- .../internal/operations/PutItemOperation.java | 4 +- .../operations/UpdateItemOperation.java | 4 +- .../dynamodb/mapper/BeanTableSchema.java | 8 ++ .../dynamodb/mapper/ImmutableTableSchema.java | 8 ++ .../mapper/StaticImmutableTableSchema.java | 19 ++- .../dynamodb/mapper/StaticTableSchema.java | 93 +++++++------ .../dynamodb/mapper/WrappedTableSchema.java | 7 +- .../document/DocumentTableSchemaTest.java | 10 +- .../AtomicCounterExtensionTest.java | 13 +- .../AutoGeneratedUuidExtensionTest.java | 7 +- .../extensions/ChainExtensionTest.java | 6 +- .../VersionedRecordExtensionTest.java | 23 +-- .../AutoGeneratedTimestampRecordTest.java | 3 +- .../AutoGeneratedUuidRecordTest.java | 3 +- .../BeanTableSchemaRecursiveTest.java | 7 +- .../ImmutableTableSchemaRecursiveTest.java | 7 +- .../functionaltests/UpdateBehaviorTest.java | 5 - .../internal/DefaultDocumentTest.java | 9 +- .../immutable/MetaTableSchemaTest.java | 14 +- .../operations/DeleteItemOperationTest.java | 16 ++- .../operations/GetItemOperationTest.java | 7 +- .../operations/PutItemOperationTest.java | 21 ++- .../TransactWriteItemsOperationTest.java | 7 +- .../operations/UpdateItemOperationTest.java | 42 ++++-- .../UpdateItemOperationTransactTest.java | 10 +- .../dynamodb/mapper/BeanTableSchemaTest.java | 131 ++++++++++++------ .../mapper/ImmutableTableSchemaTest.java | 34 +++-- .../StaticImmutableTableSchemaExtendTest.java | 4 +- ...StaticImmutableTableSchemaFlattenTest.java | 4 +- .../StaticImmutableTableSchemaTest.java | 62 +++++---- .../mapper/StaticTableSchemaTest.java | 53 ++++--- .../TransactGetItemsEnhancedRequestTest.java | 4 +- ...TransactWriteItemsEnhancedRequestTest.java | 21 +-- 38 files changed, 489 insertions(+), 260 deletions(-) create mode 100644 services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java index 91b9624f52c2..94400eb4d64d 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java @@ -22,7 +22,7 @@ import software.amazon.awssdk.annotations.ThreadSafe; import software.amazon.awssdk.enhanced.dynamodb.document.DocumentTableSchema; import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocument; -import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.ImmutableTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema; @@ -241,11 +241,25 @@ default T mapToItem(Map attributeMap, boolean preserveEm * @param ignoreNulls If set to true; any null values in the Java object will not be added to the output map. * If set to false; null values in the Java object will be added as {@link AttributeValue} of * type 'nul' to the output map. - * @param attributeMapping denotes the level of nesting, i.e. SHALLOW or NESTED, contained in the request params based + * @param requestConfiguration denotes the level of nesting, i.e. SHALLOW or NESTED, contained in the request params based * which nested update query parameters would be dealt with * @return A map of String to {@link AttributeValue} representing all the modelled attributes in the model object. */ - Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping); + Map itemToMap(T item, boolean ignoreNulls, + DynamoDBEnhancedRequestConfiguration requestConfiguration); + + /** + * This is deprecated in favour of itemToMap(T item, boolean ignoreNulls, DynamoDBEnhancedRequestOverrideConfiguration + * ddbRequestOverrideConfiguration) This method takes a modelled object and converts it into a raw map of + * {@link AttributeValue} that the DynamoDb low-level SDK can work with. + * + * @param item The modelled Java object to convert into a map of attributes. + * @param ignoreNulls If set to true; any null values in the Java object will not be added to the output map. If set to false; + * null values in the Java object will be added as {@link AttributeValue} of type 'nul' to the output map. + * @return A map of String to {@link AttributeValue} representing all the modelled attributes in the model object. + */ + @Deprecated + Map itemToMap(T item, boolean ignoreNulls); /** * Takes a modelled object and extracts a specific set of attributes which are then returned as a map of diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java index e9773b4cf786..ffac9bf81d9c 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java @@ -15,6 +15,8 @@ package software.amazon.awssdk.enhanced.dynamodb.document; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -35,9 +37,9 @@ import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.converter.ConverterProviderResolver; import software.amazon.awssdk.enhanced.dynamodb.internal.document.DefaultEnhancedDocument; -import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableMetadata; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -106,7 +108,8 @@ public EnhancedDocument mapToItem(Map attributeMap) { * */ @Override - public Map itemToMap(EnhancedDocument item, boolean ignoreNulls, AttributeMapping attributeMapping) { + public Map itemToMap(EnhancedDocument item, boolean ignoreNulls, + DynamoDBEnhancedRequestConfiguration requestConfiguration) { if (item == null) { return null; } @@ -114,6 +117,11 @@ public Map itemToMap(EnhancedDocument item, boolean igno return item.toBuilder().attributeConverterProviders(providers).build().toMap(); } + @Override + public Map itemToMap(EnhancedDocument item, boolean ignoreNulls) { + return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + } + private List mergeAttributeConverterProviders(EnhancedDocument item) { if (item.attributeConverterProviders() != null && !item.attributeConverterProviders().isEmpty()) { Set providers = new LinkedHashSet<>(); diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java new file mode 100644 index 000000000000..c757a66971b5 --- /dev/null +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java @@ -0,0 +1,36 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.enhanced.dynamodb.internal; + +import software.amazon.awssdk.annotations.SdkPublicApi; +import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; + +/** + * Configuration Object to define behaviour of DynamoDB operations. + */ +@SdkPublicApi +public class DynamoDBEnhancedRequestConfiguration { + private final AttributeMapping attributeMapping; + + public DynamoDBEnhancedRequestConfiguration(AttributeMapping attributeMapping) { + this.attributeMapping = attributeMapping; + } + + public AttributeMapping attributeMapping() { + return attributeMapping; + } + +} diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java index 73758e494479..e3001c3cb63d 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java @@ -23,6 +23,7 @@ import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.EnhancedTypeDocumentConfiguration; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; /** @@ -56,7 +57,8 @@ public static DocumentAttributeConverter create(TableSchema tableSchem @Override public AttributeValue transformFrom(T input) { - return AttributeValue.builder().m(tableSchema.itemToMap(input, ignoreNulls, SHALLOW)).build(); + return AttributeValue.builder().m(tableSchema.itemToMap(input, ignoreNulls, + new DynamoDBEnhancedRequestConfiguration(SHALLOW))).build(); } @Override diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java index a2bc8d466c40..0429e45d7f68 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java @@ -23,6 +23,7 @@ import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -51,8 +52,14 @@ public T mapToItem(Map attributeMap) { } @Override - public Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { - return concreteTableSchema().itemToMap(item, ignoreNulls, attributeMapping); + public Map itemToMap(T item, boolean ignoreNulls, + DynamoDBEnhancedRequestConfiguration requestConfiguration) { + return concreteTableSchema().itemToMap(item, ignoreNulls, requestConfiguration); + } + + @Override + public Map itemToMap(T item, boolean ignoreNulls) { + return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(AttributeMapping.SHALLOW)); } @Override diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java index fb0bf10e157e..9137d5f10f39 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java @@ -28,6 +28,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.model.PutItemEnhancedRequest; @@ -89,7 +90,8 @@ public PutItemRequest generateRequest(TableSchema tableSchema, boolean alwaysIgnoreNulls = true; T item = request.map(PutItemEnhancedRequest::item, TransactPutItemEnhancedRequest::item); - Map itemMap = tableSchema.itemToMap(item, alwaysIgnoreNulls, SHALLOW); + Map itemMap = tableSchema.itemToMap(item, alwaysIgnoreNulls, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); WriteModification transformation = extension != null ? extension.beforeWrite( diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java index b366c5c258e4..6ea058524e8a 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java @@ -33,6 +33,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionConverter; import software.amazon.awssdk.enhanced.dynamodb.model.TransactUpdateItemEnhancedRequest; @@ -91,7 +92,8 @@ public UpdateItemRequest generateRequest(TableSchema tableSchema, r -> Optional.ofNullable(r.ignoreNulls())) .orElse(null); - Map itemMap = tableSchema.itemToMap(item, Boolean.TRUE.equals(ignoreNulls), NESTED); + Map itemMap = tableSchema.itemToMap(item, Boolean.TRUE.equals(ignoreNulls), + new DynamoDBEnhancedRequestConfiguration(NESTED)); TableMetadata tableMetadata = tableSchema.tableMetadata(); WriteModification transformation = diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java index b2de876043f1..97ee701b34f2 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.enhanced.dynamodb.mapper; import static software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDbEnhancedLogger.BEAN_LOGGER; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.beans.BeanInfo; import java.beans.IntrospectionException; @@ -51,6 +52,7 @@ import software.amazon.awssdk.enhanced.dynamodb.EnhancedTypeDocumentConfiguration; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.internal.AttributeConfiguration; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.BeanAttributeGetter; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.BeanAttributeSetter; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.MetaTableSchema; @@ -65,6 +67,7 @@ import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbIgnoreNulls; import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbImmutable; import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPreserveEmptyObject; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; /** * Implementation of {@link TableSchema} that builds a table schema based on properties and annotations of a bean @@ -457,5 +460,10 @@ private static List propertyAnnotations(PropertyDescriptor private static void debugLog(Class beanClass, Supplier logMessage) { BEAN_LOGGER.debug(() -> beanClass.getTypeName() + " - " + logMessage.get()); } + + @Override + public Map itemToMap(T item, boolean ignoreNulls) { + return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + } } diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java index 9accc1fe1e91..918a7705fa8f 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java @@ -16,6 +16,7 @@ package software.amazon.awssdk.enhanced.dynamodb.mapper; import static software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDbEnhancedLogger.BEAN_LOGGER; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; @@ -46,6 +47,7 @@ import software.amazon.awssdk.enhanced.dynamodb.EnhancedTypeDocumentConfiguration; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.internal.AttributeConfiguration; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableInfo; import software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableIntrospector; import software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutablePropertyDescriptor; @@ -64,6 +66,7 @@ import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbIgnoreNulls; import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbImmutable; import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPreserveEmptyObject; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; /** * Implementation of {@link TableSchema} that builds a table schema based on properties and annotations of an immutable @@ -442,5 +445,10 @@ private static AttributeConfiguration resolveAttributeConfiguration(ImmutablePro private static void debugLog(Class beanClass, Supplier logMessage) { BEAN_LOGGER.debug(() -> beanClass.getTypeName() + " - " + logMessage.get()); } + + @Override + public Map itemToMap(T item, boolean ignoreNulls) { + return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + } } diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java index 1ea84f3d8458..cae5c2340fa7 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java @@ -18,6 +18,7 @@ import static java.util.Collections.unmodifiableMap; import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.isNullAttributeValue; import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.ArrayList; import java.util.Arrays; @@ -42,6 +43,7 @@ import software.amazon.awssdk.enhanced.dynamodb.DefaultAttributeConverterProvider; import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.converter.ConverterProviderResolver; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ResolvedImmutableAttribute; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -125,14 +127,15 @@ private B mapToItem(B thisBuilder, return thisBuilder; } - private Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { + private Map itemToMap(T item, boolean ignoreNulls, + DynamoDBEnhancedRequestConfiguration requestConfiguration) { T1 otherItem = this.otherItemGetter.apply(item); if (otherItem == null) { return Collections.emptyMap(); } - return this.otherItemTableSchema.itemToMap(otherItem, ignoreNulls, attributeMapping); + return this.otherItemTableSchema.itemToMap(otherItem, ignoreNulls, requestConfiguration); } private AttributeValue attributeValue(T item, String attributeName) { @@ -512,7 +515,8 @@ public T mapToItem(Map attributeMap) { } @Override - public Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { + public Map itemToMap(T item, boolean ignoreNulls, + DynamoDBEnhancedRequestConfiguration requestConfiguration) { Map attributeValueMap = new HashMap<>(); attributeMappers.forEach(attributeMapper -> { @@ -520,7 +524,7 @@ public Map itemToMap(T item, boolean ignoreNulls, Attrib AttributeValue attributeValue = attributeMapper.attributeGetterMethod().apply(item); if (attributeValueNonNullOrShouldWriteNull(ignoreNulls, attributeValue)) { - if (attributeMapping == NESTED && attributeValue.hasM()) { + if (requestConfiguration.attributeMapping() == NESTED && attributeValue.hasM()) { nestedItemToMap(attributeValueMap, attributeValue.m(), attributeKey, ignoreNulls); } else { attributeValueMap.put(attributeKey, attributeValue); @@ -529,12 +533,17 @@ public Map itemToMap(T item, boolean ignoreNulls, Attrib }); indexedFlattenedMappers.forEach((name, flattenedMapper) -> { - attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls, attributeMapping)); + attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls, requestConfiguration)); }); return unmodifiableMap(attributeValueMap); } + @Override + public Map itemToMap(T item, boolean ignoreNulls) { + return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + } + private void nestedItemToMap(Map resultAttributeValueMap, Map updatedItemValuesAttributeMap, String attributeKey, diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java index 6dc6b2d4f211..71ab9ddb549a 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java @@ -18,6 +18,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; @@ -31,11 +32,13 @@ import software.amazon.awssdk.enhanced.dynamodb.DefaultAttributeConverterProvider; import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; +import software.amazon.awssdk.services.dynamodb.model.AttributeValue; /** - * Implementation of {@link TableSchema} that builds a schema based on directly declared attributes and methods to - * get and set those attributes. Just like {@link StaticImmutableTableSchema} which is the equivalent implementation for - * immutable objects, this is the most direct, and thus fastest, implementation of {@link TableSchema}. + * Implementation of {@link TableSchema} that builds a schema based on directly declared attributes and methods to get and set + * those attributes. Just like {@link StaticImmutableTableSchema} which is the equivalent implementation for immutable objects, + * this is the most direct, and thus fastest, implementation of {@link TableSchema}. *

* Example using a fictional 'Customer' data item class:- *

{@code
@@ -71,6 +74,7 @@ private StaticTableSchema(Builder builder) {
 
     /**
      * Creates a builder for a {@link StaticTableSchema} typed to specific data item class.
+     *
      * @param itemClass The data item class object that the {@link StaticTableSchema} is to map to.
      * @return A newly initialized builder
      */
@@ -80,6 +84,7 @@ public static  Builder builder(Class itemClass) {
 
     /**
      * Creates a builder for a {@link StaticTableSchema} typed to specific data item class.
+     *
      * @param itemType The {@link EnhancedType} of the data item class object that the {@link StaticTableSchema} is to map to.
      * @return A newly initialized builder
      */
@@ -87,8 +92,14 @@ public static  Builder builder(EnhancedType itemType) {
         return new Builder<>(itemType);
     }
 
+    @Override
+    public Map itemToMap(T item, boolean ignoreNulls) {
+        return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(AttributeMapping.SHALLOW));
+    }
+
     /**
      * Builder for a {@link StaticTableSchema}
+     *
      * @param  The data item type that the {@link StaticTableSchema} this builder will build is to map to.
      */
     @NotThreadSafe
@@ -110,8 +121,8 @@ public Builder newItemSupplier(Supplier newItemSupplier) {
         }
 
         /**
-         * A list of attributes that can be mapped between the data item object and the database record that are to
-         * be associated with the schema. Will overwrite any existing attributes.
+         * A list of attributes that can be mapped between the data item object and the database record that are to be associated
+         * with the schema. Will overwrite any existing attributes.
          */
         @SafeVarargs
         public final Builder attributes(StaticAttribute... staticAttributes) {
@@ -123,8 +134,8 @@ public final Builder attributes(StaticAttribute... staticAttributes) {
         }
 
         /**
-         * A list of attributes that can be mapped between the data item object and the database record that are to
-         * be associated with the schema. Will overwrite any existing attributes.
+         * A list of attributes that can be mapped between the data item object and the database record that are to be associated
+         * with the schema. Will overwrite any existing attributes.
          */
         public Builder attributes(Collection> staticAttributes) {
             this.delegateBuilder.attributes(staticAttributes.stream()
@@ -134,8 +145,7 @@ public Builder attributes(Collection> staticAttributes)
         }
 
         /**
-         * Adds a single attribute to the table schema that can be mapped between the data item object and the database
-         * record.
+         * Adds a single attribute to the table schema that can be mapped between the data item object and the database record.
          */
         public  Builder addAttribute(EnhancedType attributeType,
                                            Consumer> staticAttribute) {
@@ -146,8 +156,7 @@ public  Builder addAttribute(EnhancedType attributeType,
         }
 
         /**
-         * Adds a single attribute to the table schema that can be mapped between the data item object and the database
-         * record.
+         * Adds a single attribute to the table schema that can be mapped between the data item object and the database record.
          */
         public  Builder addAttribute(Class attributeClass,
                                            Consumer> staticAttribute) {
@@ -158,8 +167,7 @@ public  Builder addAttribute(Class attributeClass,
         }
 
         /**
-         * Adds a single attribute to the table schema that can be mapped between the data item object and the database
-         * record.
+         * Adds a single attribute to the table schema that can be mapped between the data item object and the database record.
          */
         public Builder addAttribute(StaticAttribute staticAttribute) {
             this.delegateBuilder.addAttribute(staticAttribute.toImmutableAttribute());
@@ -167,8 +175,8 @@ public Builder addAttribute(StaticAttribute staticAttribute) {
         }
 
         /**
-         * Flattens all the attributes defined in another {@link StaticTableSchema} into the database record this schema
-         * maps to. Functions to get and set an object that the flattened schema maps to is required.
+         * Flattens all the attributes defined in another {@link StaticTableSchema} into the database record this schema maps to.
+         * Functions to get and set an object that the flattened schema maps to is required.
          */
         public  Builder flatten(TableSchema otherTableSchema,
                                       Function otherItemGetter,
@@ -178,8 +186,8 @@ public  Builder flatten(TableSchema otherTableSchema,
         }
 
         /**
-         * Extends the {@link StaticTableSchema} of a super-class, effectively rolling all the attributes modelled by
-         * the super-class into the {@link StaticTableSchema} of the sub-class.
+         * Extends the {@link StaticTableSchema} of a super-class, effectively rolling all the attributes modelled by the
+         * super-class into the {@link StaticTableSchema} of the sub-class.
          */
         public Builder extend(StaticTableSchema superTableSchema) {
             this.delegateBuilder.extend(superTableSchema.toImmutableTableSchema());
@@ -187,8 +195,8 @@ public Builder extend(StaticTableSchema superTableSchema) {
         }
 
         /**
-         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to
-         * understand what each one does. This method will overwrite any existing table tags.
+         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand
+         * what each one does. This method will overwrite any existing table tags.
          */
         public Builder tags(StaticTableTag... staticTableTags) {
             this.delegateBuilder.tags(staticTableTags);
@@ -196,8 +204,8 @@ public Builder tags(StaticTableTag... staticTableTags) {
         }
 
         /**
-         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to
-         * understand what each one does. This method will overwrite any existing table tags.
+         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand
+         * what each one does. This method will overwrite any existing table tags.
          */
         public Builder tags(Collection staticTableTags) {
             this.delegateBuilder.tags(staticTableTags);
@@ -205,8 +213,8 @@ public Builder tags(Collection staticTableTags) {
         }
 
         /**
-         * Associates a {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand
-         * what each one does. This method will add the tag to the list of existing table tags.
+         * Associates a {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand what each
+         * one does. This method will add the tag to the list of existing table tags.
          */
         public Builder addTag(StaticTableTag staticTableTag) {
             this.delegateBuilder.addTag(staticTableTag);
@@ -214,19 +222,16 @@ public Builder addTag(StaticTableTag staticTableTag) {
         }
 
         /**
-         * Specifies the {@link AttributeConverterProvider}s to use with the table schema.
-         * The list of attribute converter providers must provide {@link AttributeConverter}s for all types used
-         * in the schema. The attribute converter providers will be loaded in the strict order they are supplied here.
+         * Specifies the {@link AttributeConverterProvider}s to use with the table schema. The list of attribute converter
+         * providers must provide {@link AttributeConverter}s for all types used in the schema. The attribute converter providers
+         * will be loaded in the strict order they are supplied here.
          * 

- * Calling this method will override the default attribute converter provider - * {@link DefaultAttributeConverterProvider}, which provides standard converters for most primitive - * and common Java types, so that provider must included in the supplied list if it is to be - * used. Providing an empty list here will cause no providers to get loaded. + * Calling this method will override the default attribute converter provider {@link DefaultAttributeConverterProvider}, + * which provides standard converters for most primitive and common Java types, so that provider must included in the + * supplied list if it is to be used. Providing an empty list here will cause no providers to get loaded. *

* Adding one custom attribute converter provider and using the default as fallback: - * {@code - * builder.attributeConverterProviders(customAttributeConverter, AttributeConverterProvider.defaultProvider()) - * } + * {@code builder.attributeConverterProviders(customAttributeConverter, AttributeConverterProvider.defaultProvider()) } * * @param attributeConverterProviders a list of attribute converter providers to use with the table schema */ @@ -236,22 +241,17 @@ public Builder attributeConverterProviders(AttributeConverterProvider... attr } /** - * Specifies the {@link AttributeConverterProvider}s to use with the table schema. - * The list of attribute converter providers must provide {@link AttributeConverter}s for all types used - * in the schema. The attribute converter providers will be loaded in the strict order they are supplied here. + * Specifies the {@link AttributeConverterProvider}s to use with the table schema. The list of attribute converter + * providers must provide {@link AttributeConverter}s for all types used in the schema. The attribute converter providers + * will be loaded in the strict order they are supplied here. *

- * Calling this method will override the default attribute converter provider - * {@link DefaultAttributeConverterProvider}, which provides standard converters - * for most primitive and common Java types, so that provider must included in the supplied list if it is to be - * used. Providing an empty list here will cause no providers to get loaded. + * Calling this method will override the default attribute converter provider {@link DefaultAttributeConverterProvider}, + * which provides standard converters for most primitive and common Java types, so that provider must included in the + * supplied list if it is to be used. Providing an empty list here will cause no providers to get loaded. *

* Adding one custom attribute converter provider and using the default as fallback: - * {@code - * List providers = new ArrayList<>( - * customAttributeConverter, - * AttributeConverterProvider.defaultProvider()); - * builder.attributeConverterProviders(providers); - * } + * {@code List providers = new ArrayList<>( customAttributeConverter, + * AttributeConverterProvider.defaultProvider()); builder.attributeConverterProviders(providers); } * * @param attributeConverterProviders a list of attribute converter providers to use with the table schema */ @@ -276,6 +276,7 @@ private StaticImmutableTableSchema toImmutableTableSchema() { /** * The table schema {@link AttributeConverterProvider}. + * * @see Builder#attributeConverterProvider */ public AttributeConverterProvider attributeConverterProvider() { diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java index 086eb000ce08..4cd999d35ca9 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java @@ -24,6 +24,7 @@ import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; /** @@ -63,9 +64,9 @@ public T mapToItem(Map attributeMap, boolean preserveEmp } @Override - public Map itemToMap(T item, boolean ignoreNulls, AttributeMapping attributeMapping) { - - return this.delegateTableSchema.itemToMap(item, ignoreNulls, attributeMapping); + public Map itemToMap(T item, boolean ignoreNulls, + DynamoDBEnhancedRequestConfiguration requestConfiguration) { + return this.delegateTableSchema.itemToMap(item, ignoreNulls, requestConfiguration); } @Override diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java index 5257efaeb8e3..dc0d922d80a2 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java @@ -36,10 +36,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.converters.document.CustomAttributeForDocumentConverterProvider; import software.amazon.awssdk.enhanced.dynamodb.converters.document.CustomClassForDocumentAPI; -import software.amazon.awssdk.enhanced.dynamodb.document.DocumentTableSchema; -import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocument; -import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocumentTestData; -import software.amazon.awssdk.enhanced.dynamodb.document.TestData; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.converter.ChainConverterProvider; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.StaticKeyAttributeMetadata; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -126,7 +123,8 @@ void validate_DocumentTableSchemaItemToMap(TestData testData) { DocumentTableSchema documentTableSchema = DocumentTableSchema.builder().build(); Assertions.assertThat( - documentTableSchema.itemToMap(testData.getEnhancedDocument(), false, SHALLOW)).isEqualTo(testData.getDdbItemMap()); + documentTableSchema.itemToMap(testData.getEnhancedDocument(), false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW))).isEqualTo(testData.getDdbItemMap()); } @ParameterizedTest @@ -235,6 +233,6 @@ void validate_DocumentTableSchema_WithCustomIntegerAttributeProvider() { CustomAttributeForDocumentConverterProvider.create())) .build(); Assertions.assertThat( - documentTableSchema.itemToMap(numberDocument, true, SHALLOW)).isEqualTo(resultMap); + documentTableSchema.itemToMap(numberDocument, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))).isEqualTo(resultMap); } } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java index 960c72846533..3b35b16b6ebe 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java @@ -28,6 +28,7 @@ import org.junit.Test; import software.amazon.awssdk.enhanced.dynamodb.OperationContext; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.OperationName; @@ -78,7 +79,7 @@ public void beforeWrite_updateItemOperation_hasCounters_createsUpdateExpression( AtomicCounterItem atomicCounterItem = new AtomicCounterItem(); atomicCounterItem.setId(RECORD_ID); - Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); + Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(items).hasSize(1); WriteModification result = @@ -107,7 +108,7 @@ public void beforeWrite_updateItemOperation_noCounters_noChanges() { item.setId(RECORD_ID); item.setNumberAttribute(4L); - Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, SHALLOW); + Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(items).hasSize(2); WriteModification result = @@ -126,7 +127,7 @@ public void beforeWrite_updateItemOperation_hasCountersInItem_createsUpdateExpre atomicCounterItem.setId(RECORD_ID); atomicCounterItem.setCustomCounter(255L); - Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); + Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(items).hasSize(2); WriteModification result = @@ -154,7 +155,7 @@ public void beforeWrite_putItemOperation_hasCounters_createsItemTransform() { AtomicCounterItem atomicCounterItem = new AtomicCounterItem(); atomicCounterItem.setId(RECORD_ID); - Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); + Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(items).hasSize(1); WriteModification result = @@ -175,7 +176,7 @@ public void beforeWrite_putItemOperation_noCounters_noChanges() { item.setId(RECORD_ID); item.setNumberAttribute(4L); - Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, SHALLOW); + Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(items).hasSize(2); WriteModification result = @@ -193,7 +194,7 @@ public void beforeWrite_putItemOperation_noCounters_noChanges() { public void beforeRead_doesNotTransformObject() { AtomicCounterItem atomicCounterItem = new AtomicCounterItem(); atomicCounterItem.setId(RECORD_ID); - Map fakeItemMap = ITEM_MAPPER.itemToMap(atomicCounterItem, true, SHALLOW); + Map fakeItemMap = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); ReadModification result = atomicCounterExtension.afterRead(DefaultDynamoDbExtensionContext diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java index 6f910ce0cccb..89f2a9d01fe6 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import software.amazon.awssdk.enhanced.dynamodb.OperationContext; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.OperationName; @@ -73,7 +74,7 @@ public void beforeWrite_updateItemOperation_hasUuidInItem_doesNotCreateUpdateExp String uuidAttribute = String.valueOf(UUID.randomUUID()); SimpleItem.setUuidAttribute(uuidAttribute); - Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, NESTED); + Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, new DynamoDBEnhancedRequestConfiguration(NESTED)); assertThat(items).hasSize(2); WriteModification result = @@ -96,7 +97,7 @@ public void beforeWrite_updateItemOperation_hasNoUuidInItem_doesNotCreatesUpdate ItemWithUuid SimpleItem = new ItemWithUuid(); SimpleItem.setId(RECORD_ID); - Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, NESTED); + Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, new DynamoDBEnhancedRequestConfiguration(NESTED)); assertThat(items).hasSize(1); WriteModification result = @@ -118,7 +119,7 @@ public void beforeWrite_updateItemOperation_UuidNotPresent_newUuidCreated() { ItemWithUuid item = new ItemWithUuid(); item.setId(RECORD_ID); - Map items = ITEM_WITH_UUID_MAPPER.itemToMap(item, true, NESTED); + Map items = ITEM_WITH_UUID_MAPPER.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(NESTED)); assertThat(items).hasSize(1); WriteModification result = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java index 71bf07abd49f..3acdb4579c1a 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java @@ -17,11 +17,9 @@ import static java.util.stream.Collectors.toList; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.isNotNull; import static org.mockito.Mockito.when; import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; @@ -43,6 +41,7 @@ import software.amazon.awssdk.enhanced.dynamodb.OperationContext; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.ChainExtension; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext; @@ -77,7 +76,8 @@ public class ChainExtensionTest { private final List> fakeItems = IntStream.range(0, 4) .mapToObj($ -> createUniqueFakeItem()) - .map(fakeItem -> FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) + .map(fakeItem -> FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW))) .collect(toList()); @Test diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java index 1c6ae6493967..8f99f6ef3948 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java @@ -30,6 +30,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -44,7 +45,7 @@ public class VersionedRecordExtensionTest { @Test public void beforeRead_doesNotTransformObject() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); ReadModification result = versionedRecordExtension.afterRead(DefaultDynamoDbExtensionContext @@ -64,7 +65,7 @@ public void beforeWrite_initialVersion_expressionIsCorrect() { versionedRecordExtension.beforeWrite( DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -79,13 +80,13 @@ public void beforeWrite_initialVersion_expressionIsCorrect() { public void beforeWrite_initialVersion_transformedItemIsCorrect() { FakeItem fakeItem = createUniqueFakeItem(); Map fakeItemWithInitialVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))); fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("1").build()); WriteModification result = versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -97,10 +98,10 @@ public void beforeWrite_initialVersion_transformedItemIsCorrect() { public void beforeWrite_initialVersionDueToExplicitNull_transformedItemIsCorrect() { FakeItem fakeItem = createUniqueFakeItem(); Map inputMap = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))); inputMap.put("version", AttributeValue.builder().nul(true).build()); Map fakeItemWithInitialVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))); fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("1").build()); WriteModification result = @@ -121,7 +122,7 @@ public void beforeWrite_existingVersion_expressionIsCorrect() { WriteModification result = versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -139,13 +140,13 @@ public void beforeWrite_existingVersion_transformedItemIsCorrect() { FakeItem fakeItem = createUniqueFakeItem(); fakeItem.setVersion(13); Map fakeItemWithInitialVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))); fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("14").build()); WriteModification result = versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext .builder() - .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)) + .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))) .tableMetadata(FakeItem.getTableMetadata()) .operationContext(PRIMARY_CONTEXT).build()); @@ -156,7 +157,7 @@ public void beforeWrite_existingVersion_transformedItemIsCorrect() { public void beforeWrite_returnsNoOpModification_ifVersionAttributeNotDefined() { FakeItemWithSort fakeItemWithSort = createUniqueFakeItemWithSort(); Map itemMap = - new HashMap<>(FakeItemWithSort.getTableSchema().itemToMap(fakeItemWithSort, true, SHALLOW)); + new HashMap<>(FakeItemWithSort.getTableSchema().itemToMap(fakeItemWithSort, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))); WriteModification writeModification = versionedRecordExtension.beforeWrite( DefaultDynamoDbExtensionContext.builder() .items(itemMap) @@ -170,7 +171,7 @@ public void beforeWrite_returnsNoOpModification_ifVersionAttributeNotDefined() { public void beforeWrite_throwsIllegalArgumentException_ifVersionAttributeIsWrongType() { FakeItem fakeItem = createUniqueFakeItem(); Map fakeItemWIthBadVersion = - new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW)); + new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))); fakeItemWIthBadVersion.put("version", AttributeValue.builder().s("14").build()); versionedRecordExtension.beforeWrite( diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java index 5d8ee75c8efb..a897b91f070d 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java @@ -48,6 +48,7 @@ import software.amazon.awssdk.enhanced.dynamodb.converters.EpochMillisFormatTestConverter; import software.amazon.awssdk.enhanced.dynamodb.converters.TimeFormatUpdateTestConverter; import software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedTimestampRecordExtension; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema; @@ -119,7 +120,7 @@ public class AutoGeneratedTimestampRecordTest extends LocalDynamoDbSyncTestBase private final List> fakeItems = IntStream.range(0, 4) .mapToObj($ -> createUniqueFakeItem()) - .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, SHALLOW)) + .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))) .collect(toList()); private final DynamoDbTable mappedTable; diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java index cb2521a14d89..d297beb20c73 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java @@ -48,6 +48,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedUuidExtension; import software.amazon.awssdk.enhanced.dynamodb.extensions.annotations.DynamoDbAutoGeneratedUuid; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext; import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.UpdateBehavior; @@ -125,7 +126,7 @@ public AutoGeneratedUuidRecordTest(String testName, TableSchema recordTa private final List> fakeItems = IntStream.range(0, 4) .mapToObj($ -> createUniqueFakeItem()) - .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, SHALLOW)) + .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))) .collect(toList()); private DynamoDbTable mappedTable; diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java index 796f2b89364c..587ee6dcb9ad 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java @@ -24,6 +24,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordBean; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordImmutable; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; public class BeanTableSchemaRecursiveTest { @@ -49,7 +50,8 @@ public void recursiveRecord_document() { recursiveRecordBean1.setAttribute(1); recursiveRecordBean1.setRecursiveRecordBean(recursiveRecordBean2); - Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true, SHALLOW); + Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); @@ -78,7 +80,8 @@ public void recursiveRecord_list() { recursiveRecordBean1.setAttribute(1); recursiveRecordBean1.setRecursiveRecordList(Collections.singletonList(recursiveRecordBean2)); - Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true, SHALLOW); + Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java index 739b205de033..6b8a02ffc3df 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java @@ -24,6 +24,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordBean; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordImmutable; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; public class ImmutableTableSchemaRecursiveTest { @@ -51,7 +52,8 @@ public void recursiveRecord_document() { .setRecursiveRecordImmutable(recursiveRecordImmutable2) .build(); - Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true, SHALLOW); + Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); @@ -84,7 +86,8 @@ public void recursiveRecord_list() { .setRecursiveRecordList(Collections.singletonList(recursiveRecordImmutable2)) .build(); - Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true, SHALLOW); + Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap).hasSize(2); assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build()); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java index 061b55521801..24c81342accd 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java @@ -4,11 +4,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.time.Instant; -import java.util.HashMap; -import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.xml.bind.ValidationException; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -16,11 +13,9 @@ import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedTimestampRecordExtension; -import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.NestedRecordWithUpdateBehavior; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecordWithUpdateBehaviors; import software.amazon.awssdk.enhanced.dynamodb.internal.client.ExtensionResolver; -import software.amazon.awssdk.services.dynamodb.model.AttributeValue; import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; public class UpdateBehaviorTest extends LocalDynamoDbSyncTestBase { diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java index c5a94d42dadf..e3aca1ce1f75 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java @@ -62,7 +62,8 @@ private DynamoDbTable createMappedTable(DynamoDbEnhancedClientExtensio @Test public void noExtension_mapsToItem() { FakeItem fakeItem = FakeItem.createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); Document defaultDocument = DefaultDocument.create(fakeItemMap); assertThat(defaultDocument.getItem(createMappedTable(null)), is(fakeItem)); @@ -72,8 +73,10 @@ public void noExtension_mapsToItem() { public void extension_mapsToItem() { FakeItem fakeItem = FakeItem.createUniqueFakeItem(); FakeItem fakeItem2 = FakeItem.createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); - Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); when(mockDynamoDbEnhancedClientExtension.afterRead(any(DynamoDbExtensionContext.AfterRead.class))) .thenReturn(ReadModification.builder().transformedItem(fakeItemMap2).build()); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java index 69715edefd86..ce8bbcb15097 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java @@ -38,6 +38,7 @@ import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.MetaTableSchema; import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -75,17 +76,18 @@ public void mapToItem_notInitialized() { @Test public void itemToMap_ignoreNulls() { metaTableSchema.initialize(mockTableSchema); - when(mockTableSchema.itemToMap(any(FakeItem.class), any(boolean.class), any(AttributeMapping.class))).thenReturn(fakeMap); + when(mockTableSchema.itemToMap(any(FakeItem.class), any(boolean.class), any(DynamoDBEnhancedRequestConfiguration.class))).thenReturn(fakeMap); - assertThat(metaTableSchema.itemToMap(fakeItem, true, SHALLOW)).isSameAs(fakeMap); - verify(mockTableSchema).itemToMap(fakeItem, true, SHALLOW); - assertThat(metaTableSchema.itemToMap(fakeItem, false, SHALLOW)).isSameAs(fakeMap); - verify(mockTableSchema).itemToMap(fakeItem, false, SHALLOW); + DynamoDBEnhancedRequestConfiguration shallowRequestConfigurationParameter = new DynamoDBEnhancedRequestConfiguration(SHALLOW); + assertThat(metaTableSchema.itemToMap(fakeItem, true, shallowRequestConfigurationParameter)).isSameAs(fakeMap); + verify(mockTableSchema).itemToMap(fakeItem, true, shallowRequestConfigurationParameter); + assertThat(metaTableSchema.itemToMap(fakeItem, false, shallowRequestConfigurationParameter)).isSameAs(fakeMap); + verify(mockTableSchema).itemToMap(fakeItem, false, shallowRequestConfigurationParameter); } @Test public void itemToMap_ignoreNulls_notInitialized() { - assertUninitialized(t -> t.itemToMap(fakeItem, true, SHALLOW)); + assertUninitialized(t -> t.itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))); } @Test diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java index 7318adc25289..441fe3f90c86 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java @@ -50,6 +50,7 @@ import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.model.DeleteItemEnhancedRequest; import software.amazon.awssdk.enhanced.dynamodb.model.TransactDeleteItemEnhancedRequest; @@ -427,8 +428,10 @@ public void generateRequest_withExtension_doesNotModifyKey() { public void transformResponse_withExtension_appliesItemModification() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, SHALLOW); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, SHALLOW); + Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); DeleteItemOperation deleteItemOperation = DeleteItemOperation.create(DeleteItemEnhancedRequest.builder() .key(k -> k.partitionValue(baseFakeItem.getId())) @@ -457,7 +460,8 @@ public void transformResponse_withExtension_appliesItemModification() { @Test public void generateTransactWriteItem_basicRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); DeleteItemOperation deleteItemOperation = spy(DeleteItemOperation.create(DeleteItemEnhancedRequest.builder() .key(k -> k.partitionValue(fakeItem.getId())) @@ -487,7 +491,8 @@ public void generateTransactWriteItem_basicRequest() { @Test public void generateTransactWriteItem_conditionalRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); DeleteItemOperation deleteItemOperation = spy(DeleteItemOperation.create(DeleteItemEnhancedRequest.builder() .key(k -> k.partitionValue(fakeItem.getId())) @@ -527,7 +532,8 @@ public void generateTransactWriteItem_conditionalRequest() { @Test public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); String returnValues = "return-values"; DeleteItemOperation deleteItemOperation = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java index 059bd9d567aa..97185c645e29 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java @@ -45,6 +45,7 @@ import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.model.GetItemEnhancedRequest; import software.amazon.awssdk.enhanced.dynamodb.model.GetItemEnhancedResponse; @@ -246,8 +247,10 @@ public void generateRequest_withExtension_doesNotModifyKey() { public void transformResponse_withExtension_appliesItemModification() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, SHALLOW); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, SHALLOW); + Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); GetItemOperation getItemOperation = GetItemOperation.create(GetItemEnhancedRequest.builder().key(k -> k.partitionValue(baseFakeItem.getId())).build()); GetItemResponse response = GetItemResponse.builder() diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java index 7178c45123e5..81a0c6488af4 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java @@ -28,7 +28,7 @@ import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; -import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; +import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.util.Collections; import java.util.HashMap; @@ -46,6 +46,7 @@ import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.model.PutItemEnhancedRequest; import software.amazon.awssdk.enhanced.dynamodb.model.TransactPutItemEnhancedRequest; @@ -475,8 +476,10 @@ public void transformResponse_doesNotBlowUp() { public void generateRequest_withExtension_modifiesItemToPut() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) .thenReturn(WriteModification.builder().transformedItem(fakeMap).build()); PutItemOperation putItemOperation = PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class) @@ -501,7 +504,8 @@ public void generateRequest_withExtension_modifiesItemToPut() { public void generateRequest_withExtension_singleCondition() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build(); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) .thenReturn(WriteModification.builder().additionalConditionalExpression(condition).build()); @@ -536,7 +540,8 @@ public void generateRequest_withExtension_noModifications() { @Test public void generateTransactWriteItem_basicRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); PutItemOperation putItemOperation = spy(PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class) .item(fakeItem) .build())); @@ -565,7 +570,8 @@ public void generateTransactWriteItem_basicRequest() { @Test public void generateTransactWriteItem_conditionalRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); PutItemOperation putItemOperation = spy(PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class) .item(fakeItem) .build())); @@ -604,7 +610,8 @@ public void generateTransactWriteItem_conditionalRequest() { @Test public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); String returnValues = "return-values"; PutItemOperation putItemOperation = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java index f4eb970600c3..dab8c1977726 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java @@ -35,6 +35,7 @@ import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension; import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.model.TransactWriteItemsEnhancedRequest; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -49,8 +50,10 @@ public class TransactWriteItemsOperationTest { private final FakeItem fakeItem1 = FakeItem.createUniqueFakeItem(); private final FakeItem fakeItem2 = FakeItem.createUniqueFakeItem(); - private final Map fakeItemMap1 = FakeItem.getTableSchema().itemToMap(fakeItem1, true, SHALLOW); - private final Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true, SHALLOW); + private final Map fakeItemMap1 = FakeItem.getTableSchema().itemToMap(fakeItem1, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); + private final Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); @Mock private DynamoDbEnhancedClientExtension mockDynamoDbEnhancedClientExtension; diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java index d953927ced7c..c3db1166785f 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java @@ -55,6 +55,7 @@ import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext; import software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedRequest; import software.amazon.awssdk.enhanced.dynamodb.update.DeleteAction; @@ -285,8 +286,10 @@ public void generateRequest_withExtension_modifiesKeyPortionOfItem() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, NESTED); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, NESTED); + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, + new DynamoDBEnhancedRequestConfiguration(NESTED)); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, + new DynamoDBEnhancedRequestConfiguration(NESTED)); Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id")); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) @@ -308,8 +311,10 @@ public void generateRequest_withExtension_nestedAttributes() { FakeItem baseFakeItem = createUniqueFakeItemWithNestedComposedAttribute(); FakeItem fakeItem = createUniqueFakeItemWithNestedComposedAttribute(); - Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, NESTED); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, NESTED); + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, + new DynamoDBEnhancedRequestConfiguration(NESTED)); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, + new DynamoDBEnhancedRequestConfiguration(NESTED)); Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id")); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) @@ -331,8 +336,10 @@ public void generateRequest_withFlattenedMap_withNestedAttributes() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, NESTED); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, NESTED); + Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false, + new DynamoDBEnhancedRequestConfiguration(NESTED)); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, + new DynamoDBEnhancedRequestConfiguration(NESTED)); Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id")); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) @@ -352,7 +359,8 @@ public void generateRequest_withFlattenedMap_withNestedAttributes() { @Test public void generateRequest_withExtension_transformedItemModifiesUpdateExpression() { FakeItem fakeItem = createUniqueFakeItem(); - Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED)); + Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED))); Map fakeMap = new HashMap<>(baseMap); fakeMap.put("subclass_attribute", AttributeValue.builder().s("1").build()); @@ -377,7 +385,8 @@ public void generateRequest_withExtension_transformedItemModifiesUpdateExpressio public void generateRequest_withExtensions_singleCondition() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED)); Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build(); when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class))) .thenReturn(WriteModification.builder().additionalConditionalExpression(condition).build()); @@ -419,7 +428,8 @@ public void generateRequest_withExtensions_singleUpdateExpression() { public void generateRequest_withExtensions_conditionAndUpdateExpression() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED)); Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build(); Map deleteActionMap = singletonMap(":val", AttributeValue.builder().s("s").build()); @@ -547,7 +557,8 @@ public void generateRequest_withExtension_noModifications() { @Test public void generateRequest_withExtension_conditionAndModification() { FakeItem baseFakeItem = createUniqueFakeItem(); - Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED)); + Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(baseFakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED))); Map fakeMap = new HashMap<>(baseMap); fakeMap.put("subclass_attribute", AttributeValue.builder().s("1").build()); @@ -686,8 +697,10 @@ public void generateRequest_withReturnValues_knownValue_generatesCorrectRequest( public void transformResponse_withExtension_returnsCorrectTransformedItem() { FakeItem baseFakeItem = createUniqueFakeItem(); FakeItem fakeItem = createUniqueFakeItem(); - Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED); - Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED)); + Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED)); when(mockDynamoDbEnhancedClientExtension.afterRead(any(DynamoDbExtensionContext.AfterRead.class))).thenReturn( ReadModification.builder().transformedItem(fakeMap).build()); @@ -704,7 +717,8 @@ public void transformResponse_withNoOpExtension_returnsCorrectItem() { .thenReturn(ReadModification.builder().build()); FakeItem baseFakeItem = createUniqueFakeItem(); - Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, NESTED); + Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED)); FakeItem resultItem = transformResponse(baseFakeItem); @@ -801,7 +815,7 @@ private FakeItem transformResponse(FakeItem item) { UpdateItemOperation updateItemOperation = UpdateItemOperation.create(requestFakeItem(item, b -> b.ignoreNulls(true))); - Map itemMap = FakeItem.getTableSchema().itemToMap(item, true, NESTED); + Map itemMap = FakeItem.getTableSchema().itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(NESTED)); return updateItemOperation.transformResponse(UpdateItemResponse.builder().attributes(itemMap).build(), FakeItem.getTableSchema(), PRIMARY_CONTEXT, diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java index c6417257edb5..1c6ca2eafb42 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java @@ -36,6 +36,7 @@ import software.amazon.awssdk.enhanced.dynamodb.OperationContext; import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.model.TransactUpdateItemEnhancedRequest; import software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedRequest; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -54,7 +55,8 @@ public class UpdateItemOperationTransactTest { @Test public void generateTransactWriteItem_basicRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); UpdateItemOperation updateItemOperation = spy(UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).build())); OperationContext context = DefaultOperationContext.create(TABLE_NAME, TableMetadata.primaryIndexName()); @@ -90,7 +92,8 @@ public void generateTransactWriteItem_basicRequest() { @Test public void generateTransactWriteItem_conditionalRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); UpdateItemOperation updateItemOperation = spy(UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).build())); OperationContext context = DefaultOperationContext.create(TABLE_NAME, TableMetadata.primaryIndexName()); @@ -129,7 +132,8 @@ public void generateTransactWriteItem_conditionalRequest() { @Test public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() { FakeItem fakeItem = createUniqueFakeItem(); - Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); String returnValues = "return-values"; UpdateItemOperation updateItemOperation = diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java index 6f33938306ea..70976788997b 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java @@ -44,6 +44,7 @@ import software.amazon.awssdk.core.SdkBytes; import software.amazon.awssdk.enhanced.dynamodb.EnhancedType; import software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractBean; import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractImmutable; import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AttributeConverterBean; @@ -135,7 +136,8 @@ public void dynamoDbIgnore_propertyIsIgnored() { ignoredAttributeBean.setId("id-value"); ignoredAttributeBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -148,7 +150,8 @@ public void transient_propertyIsIgnored() { ignoredAttributeBean.setId("id-value"); ignoredAttributeBean.setInteger2Attribute(123); - Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -164,7 +167,8 @@ public void setterAnnotations_alsoWork() { assertThat(beanTableSchema.tableMetadata().primaryPartitionKey(), is("id")); - Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); } @@ -186,7 +190,8 @@ public void dynamoDbFlatten_correctlyFlattensBeanAttributes() { flattenedBeanBean.setAttribute1("one"); flattenedBeanBean.setAbstractBean(abstractBean); - Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -201,7 +206,8 @@ public void dynamoDbPreserveEmptyObject_shouldInitializeAsEmptyClass() { bean.setInnerBean(innerPreserveEmptyBean); - Map itemMap = beanTableSchema.itemToMap(bean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(bean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); NestedBean nestedBean = beanTableSchema.mapToItem(itemMap); assertThat(nestedBean.getInnerBean(), is(innerPreserveEmptyBean)); } @@ -214,7 +220,8 @@ public void dynamoDbIgnoreNulls_shouldOmitNulls() { bean.setInnerBean1(new AbstractBean()); bean.setInnerBean2(new AbstractBean()); - Map itemMap = beanTableSchema.itemToMap(bean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(bean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().m(new HashMap<>()).build(); assertThat(itemMap.size(), is(2)); @@ -230,7 +237,8 @@ public void dynamoDbIgnoreNulls_onList_shouldOmitNulls() { bean.setInnerBeanList1(Collections.singletonList(new AbstractBean())); bean.setInnerBeanList2(Collections.singletonList(new AbstractBean())); - Map itemMap = beanTableSchema.itemToMap(bean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(bean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().l(l -> l.m(emptyMap())).build(); AttributeValue expectedMapForInnerBean2 = AttributeValue.builder() .l(l -> l.m(singletonMap("attribute2", nullAttributeValue()))) @@ -250,7 +258,8 @@ public void dynamoDbFlatten_correctlyFlattensImmutableAttributes() { flattenedImmutableBean.setAttribute1("one"); flattenedImmutableBean.setAbstractImmutable(abstractImmutable); - Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -271,7 +280,8 @@ public void documentBean_correctlyMapsBeanAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -298,7 +308,8 @@ public void documentBean_list_correctlyMapsBeanAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -332,7 +343,8 @@ public void documentBean_map_correctlyMapsBeanAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -352,7 +364,8 @@ public void documentBean_correctlyMapsImmutableAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -377,7 +390,8 @@ public void documentBean_list_correctlyMapsImmutableAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -409,7 +423,8 @@ public void documentBean_map_correctlyMapsImmutableAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -430,7 +445,8 @@ public void parameterizedDocumentBean_correctlyMapsAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -457,7 +473,8 @@ public void parameterizedDocumentBean_list_correctlyMapsAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -491,7 +508,8 @@ public void parameterizedDocumentBean_map_correctlyMapsAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = beanTableSchema.itemToMap(documentBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(documentBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -506,7 +524,8 @@ public void extendedBean_correctlyExtendsAttributes() { extendedBean.setAttribute1("one"); extendedBean.setAttribute2("two"); - Map itemMap = beanTableSchema.itemToMap(extendedBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(extendedBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -524,7 +543,8 @@ public void itemToMap_nullAttribute_ignoreNullsTrue() { SimpleBean simpleBean = new SimpleBean(); simpleBean.setId("id-value"); - Map itemMap = beanTableSchema.itemToMap(simpleBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(simpleBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(1)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -536,7 +556,8 @@ public void itemToMap_nullAttribute_ignoreNullsFalse() { SimpleBean simpleBean = new SimpleBean(); simpleBean.setId("id-value"); - Map itemMap = beanTableSchema.itemToMap(simpleBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(simpleBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -550,7 +571,8 @@ public void itemToMap_nonNullAttribute() { simpleBean.setId("id-value"); simpleBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(simpleBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(simpleBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -603,7 +625,8 @@ public void enumBean_singleEnum() { enumBean.setId("id-value"); enumBean.setTestEnum(EnumBean.TestEnum.ONE); - Map itemMap = beanTableSchema.itemToMap(enumBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(enumBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -620,7 +643,8 @@ public void enumBean_listEnum() { enumBean.setId("id-value"); enumBean.setTestEnumList(Arrays.asList(EnumBean.TestEnum.ONE, EnumBean.TestEnum.TWO)); - Map itemMap = beanTableSchema.itemToMap(enumBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(enumBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .l(stringValue("ONE"), @@ -641,7 +665,8 @@ public void listBean_stringList() { listBean.setId("id-value"); listBean.setStringList(Arrays.asList("one", "two", "three")); - Map itemMap = beanTableSchema.itemToMap(listBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(listBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .l(stringValue("one"), @@ -664,7 +689,8 @@ public void listBean_stringListList() { listBean.setId("id-value"); listBean.setStringListList(Arrays.asList(Arrays.asList("one", "two"), Arrays.asList("three", "four"))); - Map itemMap = beanTableSchema.itemToMap(listBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(listBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue list1 = AttributeValue.builder().l(stringValue("one"), stringValue("two")).build(); AttributeValue list2 = AttributeValue.builder().l(stringValue("three"), stringValue("four")).build(); @@ -691,7 +717,8 @@ public void setBean_stringSet() { stringSet.add("three"); setBean.setStringSet(stringSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .ss("one", "two", "three") @@ -716,7 +743,8 @@ public void setBean_integerSet() { integerSet.add(3); setBean.setIntegerSet(integerSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -741,7 +769,8 @@ public void setBean_longSet() { longSet.add(3L); setBean.setLongSet(longSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -766,7 +795,8 @@ public void setBean_shortSet() { shortSet.add((short)3); setBean.setShortSet(shortSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -791,7 +821,8 @@ public void setBean_byteSet() { byteSet.add((byte)3); setBean.setByteSet(byteSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1", "2", "3") @@ -816,7 +847,8 @@ public void setBean_doubleSet() { doubleSet.add(3.3); setBean.setDoubleSet(doubleSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1.1", "2.2", "3.3") @@ -841,7 +873,8 @@ public void setBean_floatSet() { floatSet.add(3.3f); setBean.setFloatSet(floatSet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .ns("1.1", "2.2", "3.3") @@ -870,7 +903,8 @@ public void setBean_binarySet() { binarySet.add(buffer3); setBean.setBinarySet(binarySet); - Map itemMap = beanTableSchema.itemToMap(setBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(setBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder() .bs(buffer1, buffer2, buffer3) @@ -896,7 +930,8 @@ public void mapBean_stringStringMap() { mapBean.setStringMap(testMap); - Map itemMap = beanTableSchema.itemToMap(mapBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(mapBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); Map expectedMap = new HashMap<>(); expectedMap.put("one", stringValue("two")); @@ -925,7 +960,8 @@ public void mapBean_mapWithNullValue() { mapBean.setStringMap(testMap); - Map itemMap = beanTableSchema.itemToMap(mapBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(mapBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); Map expectedMap = new HashMap<>(); expectedMap.put("one", AttributeValues.nullAttributeValue()); @@ -954,7 +990,8 @@ public void mapBean_nestedStringMap() { mapBean.setNestedStringMap(testMap); - Map itemMap = beanTableSchema.itemToMap(mapBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(mapBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); Map expectedMap = new HashMap<>(); expectedMap.put("five", AttributeValue.builder().m(singletonMap("one", stringValue("two"))).build()); @@ -988,7 +1025,8 @@ public void commonTypesBean() { commonTypesBean.setFloatAttribute((float) 67.8); commonTypesBean.setBinaryAttribute(binaryLiteral); - Map itemMap = beanTableSchema.itemToMap(commonTypesBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(commonTypesBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(9)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -1019,7 +1057,8 @@ public void primitiveTypesBean() { primitiveTypesBean.setDoubleAttribute(56.7); primitiveTypesBean.setFloatAttribute((float) 67.8); - Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, true, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(8)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -1079,7 +1118,8 @@ public void usesCustomAttributeConverter() { converterBean.setIntegerAttribute(123); converterBean.setAttributeItem(attributeItem); - Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); @@ -1105,7 +1145,8 @@ public void usesCustomAttributeConverterProvider() { converterBean.setId("id-value"); converterBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value-custom"))); @@ -1119,13 +1160,14 @@ public void usesCustomAttributeConverterProvider() { @Test public void usesCustomAttributeConverterProviders() { BeanTableSchema beanTableSchema = - BeanTableSchema.create(MultipleConverterProvidersBean.class); + BeanTableSchema.create(MultipleConverterProvidersBean.class); MultipleConverterProvidersBean converterBean = new MultipleConverterProvidersBean(); converterBean.setId("id-value"); converterBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value-custom"))); @@ -1145,13 +1187,14 @@ public void emptyConverterProviderList_fails_whenAttributeConvertersAreMissing() @Test public void emptyConverterProviderList_correct_whenAttributeConvertersAreSupplied() { BeanTableSchema beanTableSchema = - BeanTableSchema.create(EmptyConverterProvidersValidBean.class); + BeanTableSchema.create(EmptyConverterProvidersValidBean.class); EmptyConverterProvidersValidBean converterBean = new EmptyConverterProvidersValidBean(); converterBean.setId("id-value"); converterBean.setIntegerAttribute(123); - Map itemMap = beanTableSchema.itemToMap(converterBean, false, SHALLOW); + Map itemMap = beanTableSchema.itemToMap(converterBean, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value-custom"))); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java index cfa8f8340a24..4a1ce52cc469 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Test; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractBean; import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractImmutable; import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.DocumentImmutable; @@ -53,7 +54,8 @@ public void documentImmutable_correctlyMapsBeanAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -83,7 +85,8 @@ public void documentImmutable_list_correctlyMapsBeanAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -119,7 +122,8 @@ public void documentImmutable_map_correctlyMapsBeanAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -140,7 +144,8 @@ public void documentImmutable_correctlyMapsImmutableAttributes() { .m(singletonMap("attribute2", stringValue("two"))) .build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -169,7 +174,8 @@ public void documentImmutable_list_correctlyMapsImmutableAttributes() { .build(); AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -203,7 +209,8 @@ public void documentImmutable_map_correctlyMapsImmutableAttributes() { expectedAttributeValueMap.put("key2", expectedDocument2); AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build(); - Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, SHALLOW); + Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -222,7 +229,8 @@ public void dynamoDbFlatten_correctlyFlattensBeanAttributes() { .setAbstractBean(abstractBean) .build(); - Map itemMap = tableSchema.itemToMap(flattenedBeanImmutable, false, SHALLOW); + Map itemMap = tableSchema.itemToMap(flattenedBeanImmutable, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -240,7 +248,8 @@ public void dynamoDbFlatten_correctlyFlattensImmutableAttributes() { .setAbstractImmutable(abstractImmutable) .build(); - Map itemMap = tableSchema.itemToMap(FlattenedImmutableImmutable, false, SHALLOW); + Map itemMap = tableSchema.itemToMap(FlattenedImmutableImmutable, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); @@ -258,7 +267,8 @@ public void dynamodbPreserveEmptyObject_shouldInitializeAsEmptyClass() { .innerBean(abstractImmutable) .build(); - Map itemMap = tableSchema.itemToMap(nestedImmutable, false, SHALLOW); + Map itemMap = tableSchema.itemToMap(nestedImmutable, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(3)); NestedImmutable result = tableSchema.mapToItem(itemMap); @@ -276,7 +286,8 @@ public void dynamoDbIgnoreNulls_shouldOmitNulls() { .innerBean2(AbstractImmutable.builder().build()) .build(); - Map itemMap = tableSchema.itemToMap(nestedImmutable, true, SHALLOW); + Map itemMap = tableSchema.itemToMap(nestedImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().m(new HashMap<>()).build(); @@ -294,7 +305,8 @@ public void toBuilderImmutable_ignoresToBuilderMethod() { .attribute1("one") .build(); - Map itemMap = toBuilderImmutableTableSchema.itemToMap(toBuilderImmutable, true, SHALLOW); + Map itemMap = toBuilderImmutableTableSchema.itemToMap(toBuilderImmutable, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(itemMap.size(), is(2)); assertThat(itemMap, hasEntry("id", stringValue("id-value"))); assertThat(itemMap, hasEntry("attribute1", stringValue("one"))); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java index 964fe91b1359..17e52bbe9544 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java @@ -24,6 +24,7 @@ import java.util.Map; import org.junit.jupiter.api.Test; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; public class StaticImmutableTableSchemaExtendTest { @@ -67,7 +68,8 @@ public class StaticImmutableTableSchemaExtendTest { @Test public void itemToMap() { - Map result = immutableTableSchema.itemToMap(TEST_RECORD, false, SHALLOW); + Map result = immutableTableSchema.itemToMap(TEST_RECORD, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(result).isEqualTo(ITEM_MAP); } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java index b24a2ca619fe..7187157179b9 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java @@ -26,6 +26,7 @@ import java.util.Map; import org.junit.jupiter.api.Test; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; public class StaticImmutableTableSchemaFlattenTest { @@ -149,7 +150,8 @@ public class StaticImmutableTableSchemaFlattenTest { @Test public void itemToMap_completeRecord() { - Map result = immutableTableSchema.itemToMap(TEST_RECORD, false, SHALLOW); + Map result = immutableTableSchema.itemToMap(TEST_RECORD, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(result).isEqualTo(ITEM_MAP); } diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java index a5572232bffe..6d6ae572c9df 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java @@ -60,6 +60,7 @@ import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.mapper.testimmutables.EntityEnvelopeImmutable; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -750,7 +751,7 @@ void setAString(String aString) { this.aString = aString; } } - + private static final Collection> ATTRIBUTES = Arrays.asList( StaticAttribute.builder(FakeMappedItem.class, Boolean.class) .name("a_primitive_boolean") @@ -824,7 +825,8 @@ public void getTableMetadata_hasCorrectFields() { @Test public void itemToMap_returnsCorrectMapWithMultipleAttributes() { - Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false, SHALLOW); + Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(attributeMap.size(), is(3)); assertThat(attributeMap, hasEntry("a_boolean", ATTRIBUTE_VALUE_B)); @@ -835,7 +837,8 @@ public void itemToMap_returnsCorrectMapWithMultipleAttributes() { @Test public void itemToMap_omitsNullAttributes() { FakeMappedItem fakeMappedItemWithNulls = FakeMappedItem.builder().aPrimitiveBoolean(true).build(); - Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true, SHALLOW); + Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(attributeMap.size(), is(1)); assertThat(attributeMap, hasEntry("a_primitive_boolean", ATTRIBUTE_VALUE_B)); @@ -904,7 +907,7 @@ public void mapperCanHandleDocument() { Map expectedMap = new HashMap<>(); expectedMap.put("documentInteger", AttributeValue.builder().n("123").build()); expectedMap.put("documentString", AttributeValue.builder().s("test-123").build()); - + verifyNullableAttribute(EnhancedType.documentOf(FakeDocument.class, FAKE_DOCUMENT_TABLE_SCHEMA), a -> a.name("value") .getter(FakeMappedItem::getAFakeDocument) @@ -1126,7 +1129,7 @@ public void mapperCanHandleNestedLists() { public void mapperCanHandleIntegerSet() { Set valueSet = new HashSet<>(asList(1, 2, 3)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Integer.class), a -> a.name("value") .getter(FakeMappedItem::getAnIntegerSet) @@ -1139,7 +1142,7 @@ public void mapperCanHandleIntegerSet() { public void mapperCanHandleStringSet() { Set valueSet = new HashSet<>(asList("one", "two", "three")); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(String.class), a -> a.name("value") .getter(FakeMappedItem::getAStringSet) @@ -1152,7 +1155,7 @@ public void mapperCanHandleStringSet() { public void mapperCanHandleLongSet() { Set valueSet = new HashSet<>(asList(1L, 2L, 3L)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Long.class), a -> a.name("value") .getter(FakeMappedItem::getALongSet) @@ -1165,7 +1168,7 @@ public void mapperCanHandleLongSet() { public void mapperCanHandleShortSet() { Set valueSet = new HashSet<>(asList((short) 1, (short) 2, (short) 3)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Short.class), a -> a.name("value") .getter(FakeMappedItem::getAShortSet) @@ -1178,7 +1181,7 @@ public void mapperCanHandleShortSet() { public void mapperCanHandleByteSet() { Set valueSet = new HashSet<>(asList((byte) 1, (byte) 2, (byte) 3)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Byte.class), a -> a.name("value") .getter(FakeMappedItem::getAByteSet) @@ -1191,7 +1194,7 @@ public void mapperCanHandleByteSet() { public void mapperCanHandleDoubleSet() { Set valueSet = new HashSet<>(asList(1.2, 3.4, 5.6)); List expectedList = valueSet.stream().map(Object::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Double.class), a -> a.name("value") .getter(FakeMappedItem::getADoubleSet) @@ -1204,7 +1207,7 @@ public void mapperCanHandleDoubleSet() { public void mapperCanHandleFloatSet() { Set valueSet = new HashSet<>(asList(1.2f, 3.4f, 5.6f)); List expectedList = valueSet.stream().map(Object::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Float.class), a -> a.name("value") .getter(FakeMappedItem::getAFloatSet) @@ -1222,7 +1225,7 @@ public void mapperCanHandleGenericMap() { Map attributeValueMap = new HashMap<>(); attributeValueMap.put("one", AttributeValue.builder().s("two").build()); attributeValueMap.put("three", AttributeValue.builder().s("four").build()); - + verifyNullableAttribute(EnhancedType.mapOf(String.class, String.class), a -> a.name("value") .getter(FakeMappedItem::getAStringMap) @@ -1240,7 +1243,7 @@ public void mapperCanHandleIntDoubleMap() { Map attributeValueMap = new HashMap<>(); attributeValueMap.put("1", AttributeValue.builder().n("1.0").build()); attributeValueMap.put("2", AttributeValue.builder().n("3.0").build()); - + verifyNullableAttribute(EnhancedType.mapOf(Integer.class, Double.class), a -> a.name("value") .getter(FakeMappedItem::getAIntDoubleMap) @@ -1292,7 +1295,8 @@ public void mapToItem_correctlyConstructsComposedClass() { public void mapToItem_preserveEmptyBean_shouldInitializeEmptyBean() { FakeItem fakeItem = new FakeItem(); - Map itemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, SHALLOW); + Map itemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); FakeItem result = FakeItem.getTableSchema().mapToItem(itemMap, true); assertThat(result, is(fakeItem)); @@ -1325,7 +1329,8 @@ public void mapToItem_nestedBeanPreserveEmptyBean_shouldInitializeEmptyBean() { FakeItemComposedClass nestedBean = new FakeItemComposedClass(); FakeItem fakeItem = new FakeItem("1", 1, nestedBean); - Map itemMap = staticTableSchema.itemToMap(fakeItem, false, SHALLOW); + Map itemMap = staticTableSchema.itemToMap(fakeItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); FakeItem result = staticTableSchema.mapToItem(itemMap); assertThat(result.getComposedObject(), is(nestedBean)); @@ -1350,7 +1355,8 @@ public void itemToMap_nestedBeanIgnoreNulls_shouldOmitNullFields() { FakeItemComposedClass nestedBean = new FakeItemComposedClass(); FakeItem fakeItem = new FakeItem("1", 1, nestedBean); - Map itemMap = staticTableSchema.itemToMap(fakeItem, true, SHALLOW); + Map itemMap = staticTableSchema.itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); AttributeValue expectedAttributeValue = AttributeValue.builder().m(new HashMap<>()).build(); assertThat(itemMap.size(), is(2)); System.out.println(itemMap); @@ -1366,7 +1372,8 @@ public void buildAbstractTableSchema() { .setter(FakeMappedItem::setAString)) .build(); - assertThat(tableSchema.itemToMap(FAKE_ITEM, false, SHALLOW), is(singletonMap("aString", stringValue("test-string")))); + assertThat(tableSchema.itemToMap(FAKE_ITEM, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap( + "aString", stringValue("test-string")))); exception.expect(UnsupportedOperationException.class); exception.expectMessage("abstract"); @@ -1385,7 +1392,7 @@ public void buildAbstractWithFlatten() { FakeDocument document = FakeDocument.of("test-string", null); FakeMappedItem item = FakeMappedItem.builder().aFakeDocument(document).build(); - assertThat(tableSchema.itemToMap(item, true, SHALLOW), + assertThat(tableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap("documentString", AttributeValue.builder().s("test-string").build()))); } @@ -1406,7 +1413,7 @@ public void buildAbstractExtends() { FakeAbstractSubclass item = new FakeAbstractSubclass(); item.setAString("test-string"); - assertThat(subclassTableSchema.itemToMap(item, true, SHALLOW), + assertThat(subclassTableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap("aString", AttributeValue.builder().s("test-string").build()))); } @@ -1489,7 +1496,8 @@ public void usesCustomAttributeConverterProvider() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1511,7 +1519,8 @@ public void usesCustomAttributeConverterProviders() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1547,7 +1556,7 @@ public void noConverterProvider_handlesCorrectly_whenAttributeConvertersAreSuppl .build(); Map resultMap = tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), - false, SHALLOW); + false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1568,7 +1577,8 @@ public void builder_canBuildForGenericClassType() { Map expectedMap = Collections.singletonMap("entity", AttributeValue.fromS("test-value")); - assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, SHALLOW), equalTo(expectedMap)); + assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), + equalTo(expectedMap)); assertThat(envelopeTableSchema.mapToItem(expectedMap).entity(), equalTo("test-value")); } @@ -1583,7 +1593,8 @@ private void verifyAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", attributeValue); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); @@ -1600,7 +1611,8 @@ private void verifyNullAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", nullAttributeValue()); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java index 7bba9ad87af5..fc7330e9ae23 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java @@ -29,7 +29,6 @@ import static org.mockito.Mockito.when; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue; import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue; -import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED; import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW; import java.math.BigDecimal; @@ -59,6 +58,7 @@ import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.EntityEnvelopeBean; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; @@ -749,7 +749,7 @@ void setAString(String aString) { this.aString = aString; } } - + private static final Collection> ATTRIBUTES = Arrays.asList( StaticAttribute.builder(FakeMappedItem.class, Boolean.class) .name("a_primitive_boolean") @@ -822,7 +822,8 @@ public void getTableMetadata_hasCorrectFields() { @Test public void itemToMap_returnsCorrectMapWithMultipleAttributes() { - Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false, SHALLOW); + Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(attributeMap.size(), is(3)); assertThat(attributeMap, hasEntry("a_boolean", ATTRIBUTE_VALUE_B)); @@ -833,7 +834,8 @@ public void itemToMap_returnsCorrectMapWithMultipleAttributes() { @Test public void itemToMap_omitsNullAttributes() { FakeMappedItem fakeMappedItemWithNulls = FakeMappedItem.builder().aPrimitiveBoolean(true).build(); - Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true, SHALLOW); + Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(attributeMap.size(), is(1)); assertThat(attributeMap, hasEntry("a_primitive_boolean", ATTRIBUTE_VALUE_B)); @@ -902,7 +904,7 @@ public void mapperCanHandleDocument() { Map expectedMap = new HashMap<>(); expectedMap.put("documentInteger", AttributeValue.builder().n("123").build()); expectedMap.put("documentString", AttributeValue.builder().s("test-123").build()); - + verifyNullableAttribute(EnhancedType.documentOf(FakeDocument.class, FAKE_DOCUMENT_TABLE_SCHEMA), a -> a.name("value") .getter(FakeMappedItem::getAFakeDocument) @@ -1124,7 +1126,7 @@ public void mapperCanHandleNestedLists() { public void mapperCanHandleIntegerSet() { Set valueSet = new HashSet<>(asList(1, 2, 3)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Integer.class), a -> a.name("value") .getter(FakeMappedItem::getAnIntegerSet) @@ -1137,7 +1139,7 @@ public void mapperCanHandleIntegerSet() { public void mapperCanHandleStringSet() { Set valueSet = new HashSet<>(asList("one", "two", "three")); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(String.class), a -> a.name("value") .getter(FakeMappedItem::getAStringSet) @@ -1150,7 +1152,7 @@ public void mapperCanHandleStringSet() { public void mapperCanHandleLongSet() { Set valueSet = new HashSet<>(asList(1L, 2L, 3L)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Long.class), a -> a.name("value") .getter(FakeMappedItem::getALongSet) @@ -1163,7 +1165,7 @@ public void mapperCanHandleLongSet() { public void mapperCanHandleShortSet() { Set valueSet = new HashSet<>(asList((short) 1, (short) 2, (short) 3)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Short.class), a -> a.name("value") .getter(FakeMappedItem::getAShortSet) @@ -1176,7 +1178,7 @@ public void mapperCanHandleShortSet() { public void mapperCanHandleByteSet() { Set valueSet = new HashSet<>(asList((byte) 1, (byte) 2, (byte) 3)); List expectedList = valueSet.stream().map(Objects::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Byte.class), a -> a.name("value") .getter(FakeMappedItem::getAByteSet) @@ -1189,7 +1191,7 @@ public void mapperCanHandleByteSet() { public void mapperCanHandleDoubleSet() { Set valueSet = new HashSet<>(asList(1.2, 3.4, 5.6)); List expectedList = valueSet.stream().map(Object::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Double.class), a -> a.name("value") .getter(FakeMappedItem::getADoubleSet) @@ -1202,7 +1204,7 @@ public void mapperCanHandleDoubleSet() { public void mapperCanHandleFloatSet() { Set valueSet = new HashSet<>(asList(1.2f, 3.4f, 5.6f)); List expectedList = valueSet.stream().map(Object::toString).collect(toList()); - + verifyNullableAttribute(EnhancedType.setOf(Float.class), a -> a.name("value") .getter(FakeMappedItem::getAFloatSet) @@ -1220,7 +1222,7 @@ public void mapperCanHandleGenericMap() { Map attributeValueMap = new HashMap<>(); attributeValueMap.put("one", AttributeValue.builder().s("two").build()); attributeValueMap.put("three", AttributeValue.builder().s("four").build()); - + verifyNullableAttribute(EnhancedType.mapOf(String.class, String.class), a -> a.name("value") .getter(FakeMappedItem::getAStringMap) @@ -1256,7 +1258,7 @@ public void mapperCanHandleIntDoubleMap() { Map attributeValueMap = new HashMap<>(); attributeValueMap.put("1", AttributeValue.builder().n("1.0").build()); attributeValueMap.put("2", AttributeValue.builder().n("3.0").build()); - + verifyNullableAttribute(EnhancedType.mapOf(Integer.class, Double.class), a -> a.name("value") .getter(FakeMappedItem::getAIntDoubleMap) @@ -1313,7 +1315,8 @@ public void buildAbstractTableSchema() { .setter(FakeMappedItem::setAString)) .build(); - assertThat(tableSchema.itemToMap(FAKE_ITEM, false, SHALLOW), is(singletonMap("aString", stringValue("test-string")))); + assertThat(tableSchema.itemToMap(FAKE_ITEM, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap( + "aString", stringValue("test-string")))); exception.expect(UnsupportedOperationException.class); exception.expectMessage("abstract"); @@ -1332,7 +1335,7 @@ public void buildAbstractWithFlatten() { FakeDocument document = FakeDocument.of("test-string", null); FakeMappedItem item = FakeMappedItem.builder().aFakeDocument(document).build(); - assertThat(tableSchema.itemToMap(item, true, SHALLOW), + assertThat(tableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap("documentString", AttributeValue.builder().s("test-string").build()))); } @@ -1353,7 +1356,7 @@ public void buildAbstractExtends() { FakeAbstractSubclass item = new FakeAbstractSubclass(); item.setAString("test-string"); - assertThat(subclassTableSchema.itemToMap(item, true, SHALLOW), + assertThat(subclassTableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap("aString", AttributeValue.builder().s("test-string").build()))); } @@ -1436,7 +1439,8 @@ public void usesCustomAttributeConverterProvider() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1458,7 +1462,8 @@ public void usesCustomAttributeConverterProviders() { .build(); Map resultMap = - tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, SHALLOW); + tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1494,7 +1499,7 @@ public void noConverterProvider_handlesCorrectly_whenAttributeConvertersAreSuppl .build(); Map resultMap = tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), - false, SHALLOW); + false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap.get("aString").s(), is(expectedString)); } @@ -1515,7 +1520,7 @@ public void builder_canBuildForGenericClassType() { Map expectedMap = Collections.singletonMap("entity", AttributeValue.fromS("test-value")); - assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, SHALLOW), equalTo(expectedMap)); + assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), equalTo(expectedMap)); assertThat(envelopeTableSchema.mapToItem(expectedMap).getEntity(), equalTo("test-value")); } @@ -1530,7 +1535,8 @@ private void verifyAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", attributeValue); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); @@ -1547,7 +1553,8 @@ private void verifyNullAttribute(EnhancedType attributeType, .build(); Map expectedMap = singletonMap("value", nullAttributeValue()); - Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, SHALLOW); + Map resultMap = tableSchema.itemToMap(fakeMappedItem, false, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); assertThat(resultMap, is(expectedMap)); FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap); diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java index cb77755af1de..20ebe03c5ceb 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java @@ -32,6 +32,7 @@ import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; import software.amazon.awssdk.services.dynamodb.model.Get; @@ -95,7 +96,8 @@ public void builder_maximal_builder_style() { private List getTransactGetItems(FakeItem fakeItem) { - final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, NESTED); + final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(NESTED)); TransactGetItem getItem = TransactGetItem.builder() .get(Get.builder() diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java index 4b707eecb714..224507eef697 100644 --- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java +++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java @@ -40,6 +40,7 @@ import software.amazon.awssdk.enhanced.dynamodb.Expression; import software.amazon.awssdk.enhanced.dynamodb.Key; import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; import software.amazon.awssdk.enhanced.dynamodb.internal.client.ExtensionResolver; import software.amazon.awssdk.enhanced.dynamodb.internal.operations.TransactWriteItemsOperation; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; @@ -90,7 +91,8 @@ public void builder_maximal_consumer_style() { .addPutItem(fakeItemMappedTable, fakeItem) .addDeleteItem(fakeItemMappedTable, fakeItem) .addUpdateItem(fakeItemMappedTable, fakeItem) - .addConditionCheck(fakeItemMappedTable, r -> r.key(k -> k.partitionValue(fakeItem.getId())) + .addConditionCheck(fakeItemMappedTable, + r -> r.key(k -> k.partitionValue(fakeItem.getId())) .conditionExpression(conditionExpression)) .build(); @@ -118,9 +120,11 @@ public void builder_maximal_shortcut_style() { TransactWriteItemsEnhancedRequest builtObject = TransactWriteItemsEnhancedRequest.builder() .addPutItem(fakeItemMappedTable, fakeItem) - .addDeleteItem(fakeItemMappedTable, Key.builder().partitionValue(fakeItem.getId()).build()) + .addDeleteItem(fakeItemMappedTable, + Key.builder().partitionValue(fakeItem.getId()).build()) .addUpdateItem(fakeItemMappedTable, fakeItem) - .addConditionCheck(fakeItemMappedTable, r -> r.key(k -> k.partitionValue(fakeItem.getId())) + .addConditionCheck(fakeItemMappedTable, + r -> r.key(k -> k.partitionValue(fakeItem.getId())) .conditionExpression(conditionExpression)) .build(); @@ -144,16 +148,16 @@ public void builder_maximal_builder_style() { .key(k -> k.partitionValue(fakeItem.getId())) .build(); UpdateItemEnhancedRequest updateItem = UpdateItemEnhancedRequest.builder(FakeItem.class) - .item(fakeItem).build(); + .item(fakeItem).build(); Expression conditionExpression = Expression.builder() .expression("#attribute = :attribute") .expressionValues(singletonMap(":attribute", stringValue("0"))) .expressionNames(singletonMap("#attribute", "attribute")) .build(); ConditionCheck conditionCheck = ConditionCheck.builder() - .key(k -> k.partitionValue(fakeItem.getId())) - .conditionExpression(conditionExpression) - .build(); + .key(k -> k.partitionValue(fakeItem.getId())) + .conditionExpression(conditionExpression) + .build(); TransactWriteItemsEnhancedRequest builtObject = TransactWriteItemsEnhancedRequest.builder() @@ -186,7 +190,8 @@ public void builder_passRequestToken_shouldWork() { } private List getTransactWriteItems(FakeItem fakeItem) { - final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, SHALLOW); + final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, + new DynamoDBEnhancedRequestConfiguration(SHALLOW)); TransactWriteItem putWriteItem = TransactWriteItem.builder() .put(Put.builder() From c06c20008b5cdb7b6aeadea220e203700fc8f1da Mon Sep 17 00:00:00 2001 From: Krishnan Date: Tue, 2 Jul 2024 09:42:41 -0700 Subject: [PATCH 06/37] Removed indendation changes --- .../dynamodb/mapper/StaticTableSchema.java | 85 ++++++++++--------- .../annotations/DynamoDbIgnoreNulls.java | 7 +- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java index 71ab9ddb549a..73f1f82459fe 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java @@ -36,9 +36,9 @@ import software.amazon.awssdk.services.dynamodb.model.AttributeValue; /** - * Implementation of {@link TableSchema} that builds a schema based on directly declared attributes and methods to get and set - * those attributes. Just like {@link StaticImmutableTableSchema} which is the equivalent implementation for immutable objects, - * this is the most direct, and thus fastest, implementation of {@link TableSchema}. + * Implementation of {@link TableSchema} that builds a schema based on directly declared attributes and methods to + * get and set those attributes. Just like {@link StaticImmutableTableSchema} which is the equivalent implementation for + * immutable objects, this is the most direct, and thus fastest, implementation of {@link TableSchema}. *

* Example using a fictional 'Customer' data item class:- *

{@code
@@ -74,7 +74,6 @@ private StaticTableSchema(Builder builder) {
 
     /**
      * Creates a builder for a {@link StaticTableSchema} typed to specific data item class.
-     *
      * @param itemClass The data item class object that the {@link StaticTableSchema} is to map to.
      * @return A newly initialized builder
      */
@@ -84,7 +83,6 @@ public static  Builder builder(Class itemClass) {
 
     /**
      * Creates a builder for a {@link StaticTableSchema} typed to specific data item class.
-     *
      * @param itemType The {@link EnhancedType} of the data item class object that the {@link StaticTableSchema} is to map to.
      * @return A newly initialized builder
      */
@@ -99,7 +97,6 @@ public Map itemToMap(T item, boolean ignoreNulls) {
 
     /**
      * Builder for a {@link StaticTableSchema}
-     *
      * @param  The data item type that the {@link StaticTableSchema} this builder will build is to map to.
      */
     @NotThreadSafe
@@ -121,8 +118,8 @@ public Builder newItemSupplier(Supplier newItemSupplier) {
         }
 
         /**
-         * A list of attributes that can be mapped between the data item object and the database record that are to be associated
-         * with the schema. Will overwrite any existing attributes.
+         * A list of attributes that can be mapped between the data item object and the database record that are to
+         * be associated with the schema. Will overwrite any existing attributes.
          */
         @SafeVarargs
         public final Builder attributes(StaticAttribute... staticAttributes) {
@@ -134,8 +131,8 @@ public final Builder attributes(StaticAttribute... staticAttributes) {
         }
 
         /**
-         * A list of attributes that can be mapped between the data item object and the database record that are to be associated
-         * with the schema. Will overwrite any existing attributes.
+         * A list of attributes that can be mapped between the data item object and the database record that are to
+         * be associated with the schema. Will overwrite any existing attributes.
          */
         public Builder attributes(Collection> staticAttributes) {
             this.delegateBuilder.attributes(staticAttributes.stream()
@@ -145,7 +142,8 @@ public Builder attributes(Collection> staticAttributes)
         }
 
         /**
-         * Adds a single attribute to the table schema that can be mapped between the data item object and the database record.
+         * Adds a single attribute to the table schema that can be mapped between the data item object and the database
+         * record.
          */
         public  Builder addAttribute(EnhancedType attributeType,
                                            Consumer> staticAttribute) {
@@ -156,7 +154,8 @@ public  Builder addAttribute(EnhancedType attributeType,
         }
 
         /**
-         * Adds a single attribute to the table schema that can be mapped between the data item object and the database record.
+         * Adds a single attribute to the table schema that can be mapped between the data item object and the database
+         * record.
          */
         public  Builder addAttribute(Class attributeClass,
                                            Consumer> staticAttribute) {
@@ -167,7 +166,8 @@ public  Builder addAttribute(Class attributeClass,
         }
 
         /**
-         * Adds a single attribute to the table schema that can be mapped between the data item object and the database record.
+         * Adds a single attribute to the table schema that can be mapped between the data item object and the database
+         * record.
          */
         public Builder addAttribute(StaticAttribute staticAttribute) {
             this.delegateBuilder.addAttribute(staticAttribute.toImmutableAttribute());
@@ -175,8 +175,8 @@ public Builder addAttribute(StaticAttribute staticAttribute) {
         }
 
         /**
-         * Flattens all the attributes defined in another {@link StaticTableSchema} into the database record this schema maps to.
-         * Functions to get and set an object that the flattened schema maps to is required.
+         * Flattens all the attributes defined in another {@link StaticTableSchema} into the database record this schema
+         * maps to. Functions to get and set an object that the flattened schema maps to is required.
          */
         public  Builder flatten(TableSchema otherTableSchema,
                                       Function otherItemGetter,
@@ -186,8 +186,8 @@ public  Builder flatten(TableSchema otherTableSchema,
         }
 
         /**
-         * Extends the {@link StaticTableSchema} of a super-class, effectively rolling all the attributes modelled by the
-         * super-class into the {@link StaticTableSchema} of the sub-class.
+         * Extends the {@link StaticTableSchema} of a super-class, effectively rolling all the attributes modelled by
+         * the super-class into the {@link StaticTableSchema} of the sub-class.
          */
         public Builder extend(StaticTableSchema superTableSchema) {
             this.delegateBuilder.extend(superTableSchema.toImmutableTableSchema());
@@ -195,8 +195,8 @@ public Builder extend(StaticTableSchema superTableSchema) {
         }
 
         /**
-         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand
-         * what each one does. This method will overwrite any existing table tags.
+         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to
+         * understand what each one does. This method will overwrite any existing table tags.
          */
         public Builder tags(StaticTableTag... staticTableTags) {
             this.delegateBuilder.tags(staticTableTags);
@@ -204,8 +204,8 @@ public Builder tags(StaticTableTag... staticTableTags) {
         }
 
         /**
-         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand
-         * what each one does. This method will overwrite any existing table tags.
+         * Associate one or more {@link StaticTableTag} with this schema. See documentation on the tags themselves to
+         * understand what each one does. This method will overwrite any existing table tags.
          */
         public Builder tags(Collection staticTableTags) {
             this.delegateBuilder.tags(staticTableTags);
@@ -213,8 +213,8 @@ public Builder tags(Collection staticTableTags) {
         }
 
         /**
-         * Associates a {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand what each
-         * one does. This method will add the tag to the list of existing table tags.
+         * Associates a {@link StaticTableTag} with this schema. See documentation on the tags themselves to understand
+         * what each one does. This method will add the tag to the list of existing table tags.
          */
         public Builder addTag(StaticTableTag staticTableTag) {
             this.delegateBuilder.addTag(staticTableTag);
@@ -222,16 +222,19 @@ public Builder addTag(StaticTableTag staticTableTag) {
         }
 
         /**
-         * Specifies the {@link AttributeConverterProvider}s to use with the table schema. The list of attribute converter
-         * providers must provide {@link AttributeConverter}s for all types used in the schema. The attribute converter providers
-         * will be loaded in the strict order they are supplied here.
+         * Specifies the {@link AttributeConverterProvider}s to use with the table schema.
+         * The list of attribute converter providers must provide {@link AttributeConverter}s for all types used
+         * in the schema. The attribute converter providers will be loaded in the strict order they are supplied here.
          * 

- * Calling this method will override the default attribute converter provider {@link DefaultAttributeConverterProvider}, - * which provides standard converters for most primitive and common Java types, so that provider must included in the - * supplied list if it is to be used. Providing an empty list here will cause no providers to get loaded. + * Calling this method will override the default attribute converter provider + * {@link DefaultAttributeConverterProvider}, which provides standard converters for most primitive + * and common Java types, so that provider must included in the supplied list if it is to be + * used. Providing an empty list here will cause no providers to get loaded. *

* Adding one custom attribute converter provider and using the default as fallback: - * {@code builder.attributeConverterProviders(customAttributeConverter, AttributeConverterProvider.defaultProvider()) } + * {@code + * builder.attributeConverterProviders(customAttributeConverter, AttributeConverterProvider.defaultProvider()) + * } * * @param attributeConverterProviders a list of attribute converter providers to use with the table schema */ @@ -241,17 +244,22 @@ public Builder attributeConverterProviders(AttributeConverterProvider... attr } /** - * Specifies the {@link AttributeConverterProvider}s to use with the table schema. The list of attribute converter - * providers must provide {@link AttributeConverter}s for all types used in the schema. The attribute converter providers - * will be loaded in the strict order they are supplied here. + * Specifies the {@link AttributeConverterProvider}s to use with the table schema. + * The list of attribute converter providers must provide {@link AttributeConverter}s for all types used + * in the schema. The attribute converter providers will be loaded in the strict order they are supplied here. *

- * Calling this method will override the default attribute converter provider {@link DefaultAttributeConverterProvider}, - * which provides standard converters for most primitive and common Java types, so that provider must included in the - * supplied list if it is to be used. Providing an empty list here will cause no providers to get loaded. + * Calling this method will override the default attribute converter provider + * {@link DefaultAttributeConverterProvider}, which provides standard converters + * for most primitive and common Java types, so that provider must included in the supplied list if it is to be + * used. Providing an empty list here will cause no providers to get loaded. *

* Adding one custom attribute converter provider and using the default as fallback: - * {@code List providers = new ArrayList<>( customAttributeConverter, - * AttributeConverterProvider.defaultProvider()); builder.attributeConverterProviders(providers); } + * {@code + * List providers = new ArrayList<>( + * customAttributeConverter, + * AttributeConverterProvider.defaultProvider()); + * builder.attributeConverterProviders(providers); + * } * * @param attributeConverterProviders a list of attribute converter providers to use with the table schema */ @@ -276,7 +284,6 @@ private StaticImmutableTableSchema toImmutableTableSchema() { /** * The table schema {@link AttributeConverterProvider}. - * * @see Builder#attributeConverterProvider */ public AttributeConverterProvider attributeConverterProvider() { diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java index 51ea54e8d1d0..da4b62db0886 100644 --- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java +++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java @@ -21,15 +21,16 @@ import java.lang.annotation.Target; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; -import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping; +import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration; /** - * Specifies that when calling {@link TableSchema#itemToMap(Object, boolean, AttributeMapping)}, a separate DynamoDB object + * Specifies that when calling {@link TableSchema#itemToMap(Object, boolean, DynamoDBEnhancedRequestConfiguration)}, a separate + * DynamoDB object * that is stored in the current object should ignore the attributes with null values. Note that if this annotation * is absent, NULL attributes will be created. * *

- * Example using {@link DynamoDbIgnoreNulls}: + * Example using {@link DynamoDbIgnoreNulls}:d *

  * 
  * @DynamoDbBean

From 5f6232d12be9e8f379c54f2412d7f7750eb08d83 Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Mon, 8 Jul 2024 01:56:22 -0700
Subject: [PATCH 07/37] Added tests for FlattenedMapper

---
 .../attribute/DocumentAttributeConverter.java |  1 -
 .../operations/UpdateItemOperation.java       | 11 +---
 .../functionaltests/UpdateBehaviorTest.java   | 61 +++++++++++++++++++
 .../models/CompositeRecord.java               | 59 ++++++++++++++++++
 .../functionaltests/models/FakeItem.java      | 13 ----
 .../models/FakeItemComposedClass.java         | 12 +---
 .../functionaltests/models/FlattenRecord.java | 51 ++++++++++++++++
 .../operations/UpdateItemOperationTest.java   | 27 --------
 8 files changed, 175 insertions(+), 60 deletions(-)
 create mode 100644 services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/CompositeRecord.java
 create mode 100644 services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FlattenRecord.java

diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
index e3001c3cb63d..93046f67066f 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
@@ -14,7 +14,6 @@
  */
 
 package software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute;
-
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import software.amazon.awssdk.annotations.SdkInternalApi;
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
index 6ea058524e8a..652ecec4e906 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
@@ -124,7 +124,8 @@ public UpdateItemRequest generateRequest(TableSchema tableSchema,
 
         UpdateItemRequest.Builder requestBuilder = UpdateItemRequest.builder()
             .tableName(operationContext.tableName())
-            .key(keyAttributes);
+            .key(keyAttributes)
+            .returnValues(ReturnValue.ALL_NEW);
 
         if (request.left().isPresent()) {
             addPlainUpdateItemParameters(requestBuilder, request.left().get());
@@ -255,14 +256,6 @@ private UpdateItemRequest.Builder addPlainUpdateItemParameters(UpdateItemRequest
         requestBuilder = requestBuilder.returnItemCollectionMetrics(enhancedRequest.returnItemCollectionMetricsAsString());
         requestBuilder =
             requestBuilder.returnValuesOnConditionCheckFailure(enhancedRequest.returnValuesOnConditionCheckFailureAsString());
-
-        // Set the default returnValue to ReturnValue.ALL_NEW if not specified
-        ReturnValue returnValue = enhancedRequest.returnValuesAsString() == null
-                                  ? ReturnValue.ALL_NEW
-                                  : ReturnValue.fromValue(enhancedRequest.returnValuesAsString());
-
-        requestBuilder.returnValues(returnValue.toString());
-
         return requestBuilder;
     }
 
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java
index 24c81342accd..69cb84fa53bb 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java
@@ -2,8 +2,11 @@
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.time.Instant;
+import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.junit.After;
@@ -13,9 +16,13 @@
 import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedTimestampRecordExtension;
+import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.CompositeRecord;
+import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FlattenRecord;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.NestedRecordWithUpdateBehavior;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecordWithUpdateBehaviors;
+import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.client.ExtensionResolver;
+import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
 
 public class UpdateBehaviorTest extends LocalDynamoDbSyncTestBase {
@@ -242,6 +249,60 @@ public void when_updatingNestedObjectWithMultipleLevels_existingInformationIsPre
         verifyMultipleLevelNestingTargetedUpdateBehavior(persistedRecord, outerNestedCounter, innerNestedCounter);
     }
 
+    @Test
+    public void when_updatingNestedObjectWithSingleLevelFlattened_existingInformationIsPreserved1() {
+        TableSchema tableSchema = TableSchema.fromClass(FlattenRecord.class);
+
+        NestedRecordWithUpdateBehavior nestedRecord = createNestedWithDefaults("id123", 10L);
+
+        CompositeRecord compositeRecord = new CompositeRecord();
+        compositeRecord.setComposedAttribute("Composite_Attribute");
+        compositeRecord.setNestedRecord(nestedRecord);
+
+        FlattenRecord flattenRecord = new FlattenRecord();
+        flattenRecord.setCompositeRecord(compositeRecord);
+        flattenRecord.setId("id456");
+
+
+        Map itemMapShallow = tableSchema.itemToMap(flattenRecord, true,
+                                                                           new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+
+        Map itemMapNested = tableSchema.itemToMap(flattenRecord, true,
+                                                                          new DynamoDBEnhancedRequestConfiguration(NESTED));
+
+
+        assertThat(itemMapShallow).hasSize(2);
+        assertThat(itemMapNested).hasSize(5);
+    }
+
+    @Test
+    public void when_updatingNestedObjectWithMultipleLevelsFlattened_existingInformationIsPreserved1() {
+        TableSchema tableSchema = TableSchema.fromClass(FlattenRecord.class);
+
+        NestedRecordWithUpdateBehavior outerNestedRecord = createNestedWithDefaults("id123", 10L);
+        NestedRecordWithUpdateBehavior innerNestedRecord = createNestedWithDefaults("id456", 11L);
+        outerNestedRecord.setNestedRecord(innerNestedRecord);
+
+        CompositeRecord compositeRecord = new CompositeRecord();
+        compositeRecord.setComposedAttribute("Composite_Attribute");
+        compositeRecord.setNestedRecord(outerNestedRecord);
+
+        FlattenRecord flattenRecord = new FlattenRecord();
+        flattenRecord.setCompositeRecord(compositeRecord);
+        flattenRecord.setId("id456");
+
+
+        Map itemMapShallow = tableSchema.itemToMap(flattenRecord, true,
+                                                                           new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+
+        Map itemMapNested = tableSchema.itemToMap(flattenRecord, true,
+                                                                          new DynamoDBEnhancedRequestConfiguration(NESTED));
+
+
+        assertThat(itemMapShallow).hasSize(2);
+        assertThat(itemMapNested).hasSize(9);
+    }
+
     /**
      * Currently, nested records are not updated through extensions.
      */
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/CompositeRecord.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/CompositeRecord.java
new file mode 100644
index 000000000000..f930f1f5b779
--- /dev/null
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/CompositeRecord.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ *  http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.enhanced.dynamodb.functionaltests.models;
+
+import java.util.Objects;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
+
+@DynamoDbBean
+public class CompositeRecord {
+    private NestedRecordWithUpdateBehavior nestedRecord;
+    private String composedAttribute;
+
+    public void setNestedRecord(NestedRecordWithUpdateBehavior nestedRecord) {
+        this.nestedRecord = nestedRecord;
+    }
+
+    public CompositeRecord setComposedAttribute(String composedAttribute) {
+        this.composedAttribute = composedAttribute;
+        return this;
+    }
+
+    public NestedRecordWithUpdateBehavior getNestedRecord() {
+        return nestedRecord;
+    }
+
+    public String getComposedAttribute() {
+        return composedAttribute;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        CompositeRecord that = (CompositeRecord) o;
+        return Objects.equals(that, this);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(nestedRecord, composedAttribute);
+    }
+}
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java
index 3dda50be83fd..246c0fd2a5e7 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItem.java
@@ -73,19 +73,6 @@ public static FakeItem createUniqueFakeItem() {
                        .build();
     }
 
-    public static FakeItem createUniqueFakeItemWithNestedComposedAttribute() {
-        return FakeItem.builder()
-                       .id(UUID.randomUUID().toString())
-                       .composedObject(FakeItemComposedClass.builder().
-                                                            nestedComposedAttribute(
-                                                                FakeItemComposedClass.builder().
-                                                                                     composedAttribute("nested").build()
-                                                            )
-                                                            .build())
-                       .build();
-
-    }
-
     public String getId() {
         return id;
     }
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java
index 3eb8683fbc71..789d78ba95b8 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FakeItemComposedClass.java
@@ -29,14 +29,12 @@ public class FakeItemComposedClass {
                          .build();
 
     private String composedAttribute;
-    private FakeItemComposedClass nestedFakeItemComposedClass;
 
     public FakeItemComposedClass() {
     }
 
-    public FakeItemComposedClass(String composedAttribute, FakeItemComposedClass nestedFakeItemComposedClass) {
+    public FakeItemComposedClass(String composedAttribute) {
         this.composedAttribute = composedAttribute;
-        this.nestedFakeItemComposedClass = nestedFakeItemComposedClass;
     }
 
     public static Builder builder() {
@@ -70,20 +68,14 @@ public int hashCode() {
 
     public static class Builder {
         private String composedAttribute;
-        private FakeItemComposedClass nestedFakeItemComposedClass;
 
         public Builder composedAttribute(String composedAttribute) {
             this.composedAttribute = composedAttribute;
             return this;
         }
 
-        public Builder nestedComposedAttribute(FakeItemComposedClass nestedFakeItemComposedClass) {
-            this.nestedFakeItemComposedClass = nestedFakeItemComposedClass;
-            return this;
-        }
-
         public FakeItemComposedClass build() {
-            return new FakeItemComposedClass(composedAttribute, nestedFakeItemComposedClass);
+            return new FakeItemComposedClass(composedAttribute);
         }
     }
 }
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FlattenRecord.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FlattenRecord.java
new file mode 100644
index 000000000000..8506fdf5468f
--- /dev/null
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/models/FlattenRecord.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ *  http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.enhanced.dynamodb.functionaltests.models;
+
+import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbFlatten;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey;
+
+@DynamoDbBean
+public class FlattenRecord {
+    private String id;
+    private String flattenBehaviourAttribute;
+    private CompositeRecord compositeRecord;
+
+    @DynamoDbPartitionKey
+    public String getId() {
+        return this.id;
+    }
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getFlattenBehaviourAttribute() {
+        return flattenBehaviourAttribute;
+    }
+    public void setFlattenBehaviourAttribute(String flattenBehaviourAttribute) {
+        this.flattenBehaviourAttribute = flattenBehaviourAttribute;
+    }
+
+    @DynamoDbFlatten
+    public CompositeRecord getCompositeRecord() {
+        return compositeRecord;
+    }
+    public void setCompositeRecord(CompositeRecord compositeRecord) {
+        this.compositeRecord = compositeRecord;
+    }
+}
+
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java
index c3db1166785f..e5747437d3b6 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java
@@ -29,11 +29,9 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
-import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItemWithNestedComposedAttribute;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -306,31 +304,6 @@ public void generateRequest_withExtension_modifiesKeyPortionOfItem() {
         verify(mockDynamoDbEnhancedClientExtension).beforeWrite(extensionContext(baseMap, b -> b.operationName(OperationName.UPDATE_ITEM)));
     }
 
-    @Test
-    public void generateRequest_withExtension_nestedAttributes() {
-        FakeItem baseFakeItem = createUniqueFakeItemWithNestedComposedAttribute();
-        FakeItem fakeItem = createUniqueFakeItemWithNestedComposedAttribute();
-
-        Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
-        Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id"));
-
-        when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class)))
-            .thenReturn(WriteModification.builder().transformedItem(fakeMap).build());
-
-        UpdateItemOperation updateItemOperation =
-            UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(baseFakeItem).build());
-
-        UpdateItemRequest request = updateItemOperation.generateRequest(FakeItem.getTableSchema(),
-                                                                        PRIMARY_CONTEXT,
-                                                                        mockDynamoDbEnhancedClientExtension);
-
-        assertThat(request.key(), is(keyMap));
-        verify(mockDynamoDbEnhancedClientExtension).beforeWrite(extensionContext(baseMap, b -> b.operationName(OperationName.UPDATE_ITEM)));
-    }
-
     @Test
     public void generateRequest_withFlattenedMap_withNestedAttributes() {
         FakeItem baseFakeItem = createUniqueFakeItem();

From ca54c253d93db9f476b7cfbbf8241b5a226e7650 Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Mon, 8 Jul 2024 12:05:11 -0700
Subject: [PATCH 08/37] fixed indendation

---
 .../TransactWriteItemsEnhancedRequestTest.java  | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java
index 224507eef697..e34963c1abb0 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java
@@ -91,8 +91,7 @@ public void builder_maximal_consumer_style() {
                                              .addPutItem(fakeItemMappedTable, fakeItem)
                                              .addDeleteItem(fakeItemMappedTable, fakeItem)
                                              .addUpdateItem(fakeItemMappedTable, fakeItem)
-                                             .addConditionCheck(fakeItemMappedTable,
-                                                                r -> r.key(k -> k.partitionValue(fakeItem.getId()))
+                                             .addConditionCheck(fakeItemMappedTable, r -> r.key(k -> k.partitionValue(fakeItem.getId()))
                                                                                            .conditionExpression(conditionExpression))
                                              .build();
 
@@ -120,11 +119,9 @@ public void builder_maximal_shortcut_style() {
         TransactWriteItemsEnhancedRequest builtObject =
             TransactWriteItemsEnhancedRequest.builder()
                                              .addPutItem(fakeItemMappedTable, fakeItem)
-                                             .addDeleteItem(fakeItemMappedTable,
-                                                            Key.builder().partitionValue(fakeItem.getId()).build())
+                                             .addDeleteItem(fakeItemMappedTable, Key.builder().partitionValue(fakeItem.getId()).build())
                                              .addUpdateItem(fakeItemMappedTable, fakeItem)
-                                             .addConditionCheck(fakeItemMappedTable,
-                                                                r -> r.key(k -> k.partitionValue(fakeItem.getId()))
+                                             .addConditionCheck(fakeItemMappedTable, r -> r.key(k -> k.partitionValue(fakeItem.getId()))
                                                                                            .conditionExpression(conditionExpression))
                                              .build();
 
@@ -148,16 +145,16 @@ public void builder_maximal_builder_style() {
                                                                         .key(k -> k.partitionValue(fakeItem.getId()))
                                                                         .build();
         UpdateItemEnhancedRequest updateItem = UpdateItemEnhancedRequest.builder(FakeItem.class)
-                                                                                  .item(fakeItem).build();
+                                                                        .item(fakeItem).build();
         Expression conditionExpression = Expression.builder()
                                                    .expression("#attribute = :attribute")
                                                    .expressionValues(singletonMap(":attribute", stringValue("0")))
                                                    .expressionNames(singletonMap("#attribute", "attribute"))
                                                    .build();
         ConditionCheck conditionCheck = ConditionCheck.builder()
-                                                                .key(k -> k.partitionValue(fakeItem.getId()))
-                                                                .conditionExpression(conditionExpression)
-                                                                .build();
+                                                      .key(k -> k.partitionValue(fakeItem.getId()))
+                                                      .conditionExpression(conditionExpression)
+                                                      .build();
 
         TransactWriteItemsEnhancedRequest builtObject =
             TransactWriteItemsEnhancedRequest.builder()

From ac7033a80a972f1a086ebb0b18f32d2fb270c73c Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Mon, 8 Jul 2024 22:52:24 -0700
Subject: [PATCH 09/37] Fix indendation and remove unintentional changes

---
 .../attribute/DocumentAttributeConverter.java         |  1 +
 .../internal/operations/UpdateItemOperation.java      | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
index 93046f67066f..e3001c3cb63d 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
@@ -14,6 +14,7 @@
  */
 
 package software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute;
+
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import software.amazon.awssdk.annotations.SdkInternalApi;
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
index 652ecec4e906..6ea058524e8a 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
@@ -124,8 +124,7 @@ public UpdateItemRequest generateRequest(TableSchema tableSchema,
 
         UpdateItemRequest.Builder requestBuilder = UpdateItemRequest.builder()
             .tableName(operationContext.tableName())
-            .key(keyAttributes)
-            .returnValues(ReturnValue.ALL_NEW);
+            .key(keyAttributes);
 
         if (request.left().isPresent()) {
             addPlainUpdateItemParameters(requestBuilder, request.left().get());
@@ -256,6 +255,14 @@ private UpdateItemRequest.Builder addPlainUpdateItemParameters(UpdateItemRequest
         requestBuilder = requestBuilder.returnItemCollectionMetrics(enhancedRequest.returnItemCollectionMetricsAsString());
         requestBuilder =
             requestBuilder.returnValuesOnConditionCheckFailure(enhancedRequest.returnValuesOnConditionCheckFailureAsString());
+
+        // Set the default returnValue to ReturnValue.ALL_NEW if not specified
+        ReturnValue returnValue = enhancedRequest.returnValuesAsString() == null
+                                  ? ReturnValue.ALL_NEW
+                                  : ReturnValue.fromValue(enhancedRequest.returnValuesAsString());
+
+        requestBuilder.returnValues(returnValue.toString());
+
         return requestBuilder;
     }
 

From 47937098fe225eed3da72598b085cd729ea2a0c3 Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Thu, 11 Jul 2024 01:01:16 -0700
Subject: [PATCH 10/37] Configured MappingConfiguration object

---
 .../awssdk/enhanced/dynamodb/TableSchema.java |  18 ++-
 .../document/DocumentTableSchema.java         |   8 +-
 .../DynamoDBEnhancedRequestConfiguration.java |  36 -----
 .../internal/EnhancedClientUtils.java         |  11 +-
 .../attribute/DocumentAttributeConverter.java |   9 +-
 .../internal/mapper/MetaTableSchema.java      |  15 +-
 .../internal/operations/PutItemOperation.java |   6 +-
 .../operations/UpdateItemOperation.java       |   7 +-
 .../dynamodb/mapper/AttributeMapping.java     |   3 +
 .../dynamodb/mapper/BeanTableSchema.java      |   8 --
 .../dynamodb/mapper/ImmutableTableSchema.java |   8 --
 .../dynamodb/mapper/MappingConfiguration.java | 124 +++++++++++++++++
 .../mapper/StaticImmutableTableSchema.java    |  17 +--
 .../dynamodb/mapper/StaticTableSchema.java    |   8 --
 .../dynamodb/mapper/WrappedTableSchema.java   |  14 +-
 .../annotations/DynamoDbIgnoreNulls.java      |   6 +-
 .../document/DocumentTableSchemaTest.java     |  11 +-
 .../AtomicCounterExtensionTest.java           |  14 +-
 .../AutoGeneratedUuidExtensionTest.java       |   8 +-
 .../extensions/ChainExtensionTest.java        |   7 +-
 .../VersionedRecordExtensionTest.java         |  24 ++--
 .../AutoGeneratedTimestampRecordTest.java     |   4 +-
 .../AutoGeneratedUuidRecordTest.java          |   4 +-
 .../BeanTableSchemaRecursiveTest.java         |   8 +-
 .../ImmutableTableSchemaRecursiveTest.java    |   8 +-
 .../functionaltests/UpdateBehaviorTest.java   |  19 ++-
 .../internal/DefaultDocumentTest.java         |  14 +-
 .../immutable/MetaTableSchemaTest.java        |  24 ++--
 .../operations/DeleteItemOperationTest.java   |  23 +--
 .../operations/GetItemOperationTest.java      |  12 +-
 .../operations/PutItemOperationTest.java      |  27 ++--
 .../TransactWriteItemsOperationTest.java      |  13 +-
 .../operations/UpdateItemOperationTest.java   |  50 +++----
 .../UpdateItemOperationTransactTest.java      |  15 +-
 .../dynamodb/mapper/BeanTableSchemaTest.java  | 131 ++++++------------
 .../mapper/ImmutableTableSchemaTest.java      |  35 ++---
 .../mapper/MappingConfigurationTest.java      |  55 ++++++++
 .../StaticImmutableTableSchemaExtendTest.java |   5 +-
 ...StaticImmutableTableSchemaFlattenTest.java |   5 +-
 .../StaticImmutableTableSchemaTest.java       |  41 ++----
 .../mapper/StaticTableSchemaTest.java         |  31 ++---
 .../TransactGetItemsEnhancedRequestTest.java  |   5 +-
 ...TransactWriteItemsEnhancedRequestTest.java |   5 +-
 43 files changed, 472 insertions(+), 424 deletions(-)
 delete mode 100644 services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java
 create mode 100644 services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfiguration.java
 create mode 100644 services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfigurationTest.java

diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
index 94400eb4d64d..eb94ad2df6a1 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/TableSchema.java
@@ -22,9 +22,9 @@
 import software.amazon.awssdk.annotations.ThreadSafe;
 import software.amazon.awssdk.enhanced.dynamodb.document.DocumentTableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocument;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.ImmutableTableSchema;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
@@ -238,19 +238,17 @@ default T mapToItem(Map attributeMap, boolean preserveEm
      * SDK can work with.
      *
      * @param item The modelled Java object to convert into a map of attributes.
-     * @param ignoreNulls If set to true; any null values in the Java object will not be added to the output map.
-     *                    If set to false; null values in the Java object will be added as {@link AttributeValue} of
-     *                    type 'nul' to the output map.
-     * @param requestConfiguration denotes the level of nesting, i.e. SHALLOW or NESTED, contained in the request params based
-     * which nested update query parameters would be dealt with
+     * @param configuration configuration options for mapping an object to a map with attribute values
      * @return A map of String to {@link AttributeValue} representing all the modelled attributes in the model object.
      */
-    Map itemToMap(T item, boolean ignoreNulls,
-                                          DynamoDBEnhancedRequestConfiguration requestConfiguration);
+    default Map itemToMap(T item,
+                                          MappingConfiguration configuration) {
+        throw new UnsupportedOperationException();
+    }
 
     /**
-     * This is deprecated in favour of itemToMap(T item, boolean ignoreNulls, DynamoDBEnhancedRequestOverrideConfiguration
-     * ddbRequestOverrideConfiguration) This method takes a modelled object and converts it into a raw map of
+     * This is deprecated in favour of itemToMap(T item, MappingConfiguration
+     * configuration) This method takes a modelled object and converts it into a raw map of
      * {@link AttributeValue} that the DynamoDb low-level SDK can work with.
      *
      * @param item        The modelled Java object to convert into a map of attributes.
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java
index ffac9bf81d9c..0e99192d07c6 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchema.java
@@ -15,6 +15,7 @@
 
 package software.amazon.awssdk.enhanced.dynamodb.document;
 
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.ArrayList;
@@ -37,9 +38,9 @@
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedType;
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.converter.ConverterProviderResolver;
 import software.amazon.awssdk.enhanced.dynamodb.internal.document.DefaultEnhancedDocument;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableMetadata;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -108,8 +109,7 @@ public EnhancedDocument mapToItem(Map attributeMap) {
      *
      */
     @Override
-    public Map itemToMap(EnhancedDocument item, boolean ignoreNulls,
-                                                 DynamoDBEnhancedRequestConfiguration requestConfiguration) {
+    public Map itemToMap(EnhancedDocument item, MappingConfiguration configuration) {
         if (item == null) {
             return null;
         }
@@ -119,7 +119,7 @@ public Map itemToMap(EnhancedDocument item, boolean igno
 
     @Override
     public Map itemToMap(EnhancedDocument item, boolean ignoreNulls) {
-        return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        return itemToMap(item, getMappingConfiguration(ignoreNulls, SHALLOW));
     }
 
     private List mergeAttributeConverterProviders(EnhancedDocument item) {
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java
deleted file mode 100644
index c757a66971b5..000000000000
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/DynamoDBEnhancedRequestConfiguration.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- *  http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package software.amazon.awssdk.enhanced.dynamodb.internal;
-
-import software.amazon.awssdk.annotations.SdkPublicApi;
-import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping;
-
-/**
- * Configuration Object to define behaviour of DynamoDB operations.
- */
-@SdkPublicApi
-public class DynamoDBEnhancedRequestConfiguration {
-    private final AttributeMapping attributeMapping;
-
-    public DynamoDBEnhancedRequestConfiguration(AttributeMapping attributeMapping) {
-        this.attributeMapping = attributeMapping;
-    }
-
-    public AttributeMapping attributeMapping() {
-        return attributeMapping;
-    }
-
-}
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java
index 9a19753784a3..b462a06cdf9c 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/EnhancedClientUtils.java
@@ -34,6 +34,8 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.extensions.ReadModification;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.model.Page;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 import software.amazon.awssdk.services.dynamodb.model.ConsumedCapacity;
@@ -93,7 +95,7 @@ public static String valueRef(String value) {
         String cleanAttributeName = cleanAttributeName(value);
         cleanAttributeName = isNestedAttribute(cleanAttributeName) ?
                              PATTERN.matcher(cleanAttributeName).replaceAll("_")
-                                                      : cleanAttributeName;
+                                                                   : cleanAttributeName;
         return ":AMZN_MAPPED_" + cleanAttributeName;
     }
 
@@ -204,4 +206,11 @@ public static  List getItemsFromSupplier(List> itemSupplierLis
     public static boolean isNullAttributeValue(AttributeValue attributeValue) {
         return attributeValue.nul() != null && attributeValue.nul();
     }
+
+    public static MappingConfiguration getMappingConfiguration(boolean ignoreNulls, AttributeMapping attributeMapping) {
+        return MappingConfiguration.builder()
+                                   .ignoreNulls(ignoreNulls)
+                                   .attributeMapping(attributeMapping)
+                                   .build();
+    }
 }
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
index e3001c3cb63d..cfbe4a3e3860 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/converter/attribute/DocumentAttributeConverter.java
@@ -23,7 +23,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedType;
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedTypeDocumentConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 /**
@@ -57,8 +57,11 @@ public static  DocumentAttributeConverter create(TableSchema tableSchem
 
     @Override
     public AttributeValue transformFrom(T input) {
-        return AttributeValue.builder().m(tableSchema.itemToMap(input, ignoreNulls,
-                                                                new DynamoDBEnhancedRequestConfiguration(SHALLOW))).build();
+        return AttributeValue.builder().m(tableSchema.itemToMap(input,
+                                                                MappingConfiguration.builder()
+                                                                                    .ignoreNulls(ignoreNulls)
+                                                                                    .attributeMapping(SHALLOW)
+                                                                                    .build())).build();
     }
 
     @Override
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java
index 0429e45d7f68..7f2ad9e15561 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/MetaTableSchema.java
@@ -15,6 +15,9 @@
 
 package software.amazon.awssdk.enhanced.dynamodb.internal.mapper;
 
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -23,8 +26,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedType;
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
-import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 /**
@@ -52,14 +54,13 @@ public T mapToItem(Map attributeMap) {
     }
 
     @Override
-    public Map itemToMap(T item, boolean ignoreNulls,
-                                                 DynamoDBEnhancedRequestConfiguration requestConfiguration) {
-        return concreteTableSchema().itemToMap(item, ignoreNulls, requestConfiguration);
+    public Map itemToMap(T item, boolean ignoreNulls) {
+        return itemToMap(item, getMappingConfiguration(ignoreNulls, SHALLOW));
     }
 
     @Override
-    public Map itemToMap(T item, boolean ignoreNulls) {
-        return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(AttributeMapping.SHALLOW));
+    public Map itemToMap(T item, MappingConfiguration configuration) {
+        return concreteTableSchema().itemToMap(item, configuration);
     }
 
     @Override
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java
index 9137d5f10f39..650bab7395a8 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperation.java
@@ -15,6 +15,7 @@
 
 package software.amazon.awssdk.enhanced.dynamodb.internal.operations;
 
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Map;
@@ -28,7 +29,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.model.PutItemEnhancedRequest;
@@ -90,8 +90,8 @@ public PutItemRequest generateRequest(TableSchema tableSchema,
 
         boolean alwaysIgnoreNulls = true;
         T item = request.map(PutItemEnhancedRequest::item, TransactPutItemEnhancedRequest::item);
-        Map itemMap = tableSchema.itemToMap(item, alwaysIgnoreNulls,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(item,
+                                                                    getMappingConfiguration(alwaysIgnoreNulls, SHALLOW));
 
         WriteModification transformation =
             extension != null ? extension.beforeWrite(
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
index 6ea058524e8a..cab96df145a7 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperation.java
@@ -15,6 +15,7 @@
 
 package software.amazon.awssdk.enhanced.dynamodb.internal.operations;
 
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.readAndTransformSingleItem;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionUtils.operationExpression;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
@@ -33,7 +34,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.update.UpdateExpressionConverter;
 import software.amazon.awssdk.enhanced.dynamodb.model.TransactUpdateItemEnhancedRequest;
@@ -92,8 +92,9 @@ public UpdateItemRequest generateRequest(TableSchema tableSchema,
                                           r -> Optional.ofNullable(r.ignoreNulls()))
                                      .orElse(null);
 
-        Map itemMap = tableSchema.itemToMap(item, Boolean.TRUE.equals(ignoreNulls),
-                                                                    new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map itemMap = tableSchema.itemToMap(item,
+                                                                    getMappingConfiguration(Boolean.TRUE.equals(ignoreNulls),
+                                                                                            NESTED));
         TableMetadata tableMetadata = tableSchema.tableMetadata();
 
         WriteModification transformation =
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java
index 92dfb313535c..0c044090492b 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java
@@ -15,6 +15,9 @@
 
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
+import software.amazon.awssdk.annotations.SdkPublicApi;
+
+@SdkPublicApi
 public enum AttributeMapping {
     SHALLOW,
     NESTED
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java
index 97ee701b34f2..b2de876043f1 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchema.java
@@ -16,7 +16,6 @@
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
 import static software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDbEnhancedLogger.BEAN_LOGGER;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
@@ -52,7 +51,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedTypeDocumentConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.internal.AttributeConfiguration;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.BeanAttributeGetter;
 import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.BeanAttributeSetter;
 import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.MetaTableSchema;
@@ -67,7 +65,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbIgnoreNulls;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbImmutable;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPreserveEmptyObject;
-import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 /**
  * Implementation of {@link TableSchema} that builds a table schema based on properties and annotations of a bean
@@ -460,10 +457,5 @@ private static List propertyAnnotations(PropertyDescriptor
     private static void debugLog(Class beanClass, Supplier logMessage) {
         BEAN_LOGGER.debug(() -> beanClass.getTypeName() + " - " + logMessage.get());
     }
-
-    @Override
-    public Map itemToMap(T item, boolean ignoreNulls) {
-        return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
-    }
 }
 
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java
index 918a7705fa8f..9accc1fe1e91 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchema.java
@@ -16,7 +16,6 @@
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
 import static software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDbEnhancedLogger.BEAN_LOGGER;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
@@ -47,7 +46,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedTypeDocumentConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.internal.AttributeConfiguration;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableInfo;
 import software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableIntrospector;
 import software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutablePropertyDescriptor;
@@ -66,7 +64,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbIgnoreNulls;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbImmutable;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPreserveEmptyObject;
-import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 /**
  * Implementation of {@link TableSchema} that builds a table schema based on properties and annotations of an immutable
@@ -445,10 +442,5 @@ private static AttributeConfiguration resolveAttributeConfiguration(ImmutablePro
     private static void debugLog(Class beanClass, Supplier logMessage) {
         BEAN_LOGGER.debug(() -> beanClass.getTypeName() + " - " + logMessage.get());
     }
-
-    @Override
-    public Map itemToMap(T item, boolean ignoreNulls) {
-        return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
-    }
 }
 
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfiguration.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfiguration.java
new file mode 100644
index 000000000000..83890348a2d0
--- /dev/null
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfiguration.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ *  http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.enhanced.dynamodb.mapper;
+
+import software.amazon.awssdk.annotations.SdkPublicApi;
+import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
+import software.amazon.awssdk.utils.ToString;
+import software.amazon.awssdk.utils.builder.CopyableBuilder;
+import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
+
+/**
+ * Configuration Object to define behaviour of DynamoDB operations.
+ */
+
+@SdkPublicApi
+public final class MappingConfiguration implements
+                                  ToCopyableBuilder {
+
+    /**
+     * @param AttributeMapping toggles between SHALLOW and NESTED to denote the mode of operation for the request
+     */
+    private final AttributeMapping attributeMapping;
+
+    /**
+     * @param ignoreNulls If set to true; any null values in the Java object will not be added to the output map. If set to false;
+     * null values in the Java object will be added as {@link AttributeValue} of type 'nul' to the output map.
+     */
+    private final boolean ignoreNulls;
+
+    private MappingConfiguration(Builder builder) {
+        this.attributeMapping = builder.attributeMapping;
+        this.ignoreNulls = builder.ignoreNulls;
+    }
+
+    public AttributeMapping attributeMapping() {
+        return this.attributeMapping;
+    }
+
+    public boolean ignoreNulls() {
+        return this.ignoreNulls;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    @Override
+    public Builder toBuilder() {
+        return new Builder()
+            .attributeMapping(attributeMapping)
+            .ignoreNulls(ignoreNulls);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        MappingConfiguration that = (MappingConfiguration) o;
+
+        if (attributeMapping != that.attributeMapping) {
+            return false;
+        }
+        return ignoreNulls == that.ignoreNulls;
+        
+    }
+
+    @Override
+    public int hashCode() {
+        int result = attributeMapping != null ? attributeMapping.hashCode() : 0;
+        result = 31 * result + Boolean.hashCode(ignoreNulls);
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return ToString.builder("MappingConfiguration")
+                       .add("attributeMapping", attributeMapping)
+                       .add("ignoreNulls", ignoreNulls)
+                       .build();
+    }
+
+    public static final class Builder implements CopyableBuilder {
+
+        private AttributeMapping attributeMapping;
+        private boolean ignoreNulls;
+
+        private Builder() {
+
+        }
+
+        public Builder attributeMapping(AttributeMapping attributeMapping) {
+            this.attributeMapping = attributeMapping;
+            return this;
+        }
+
+        public Builder ignoreNulls(boolean ignoreNulls) {
+            this.ignoreNulls = ignoreNulls;
+            return this;
+        }
+
+        @Override
+        public MappingConfiguration build() {
+            return new MappingConfiguration(this);
+        }
+    }
+}
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java
index cae5c2340fa7..9eb87157aafc 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchema.java
@@ -16,6 +16,7 @@
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
 import static java.util.Collections.unmodifiableMap;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.isNullAttributeValue;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
@@ -43,7 +44,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.DefaultAttributeConverterProvider;
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedType;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.converter.ConverterProviderResolver;
 import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ResolvedImmutableAttribute;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -128,14 +128,14 @@ private B mapToItem(B thisBuilder,
         }
 
         private Map itemToMap(T item, boolean ignoreNulls,
-                                                      DynamoDBEnhancedRequestConfiguration requestConfiguration) {
+                                                      MappingConfiguration configuration) {
             T1 otherItem = this.otherItemGetter.apply(item);
 
             if (otherItem == null) {
                 return Collections.emptyMap();
             }
 
-            return this.otherItemTableSchema.itemToMap(otherItem, ignoreNulls, requestConfiguration);
+            return this.otherItemTableSchema.itemToMap(otherItem, configuration);
         }
 
         private AttributeValue attributeValue(T item, String attributeName) {
@@ -515,8 +515,9 @@ public T mapToItem(Map attributeMap) {
     }
 
     @Override
-    public Map itemToMap(T item, boolean ignoreNulls,
-                                                 DynamoDBEnhancedRequestConfiguration requestConfiguration) {
+    public Map itemToMap(T item,
+                                                 MappingConfiguration configuration) {
+        boolean ignoreNulls = configuration.ignoreNulls();
         Map attributeValueMap = new HashMap<>();
 
         attributeMappers.forEach(attributeMapper -> {
@@ -524,7 +525,7 @@ public Map itemToMap(T item, boolean ignoreNulls,
             AttributeValue attributeValue = attributeMapper.attributeGetterMethod().apply(item);
 
             if (attributeValueNonNullOrShouldWriteNull(ignoreNulls, attributeValue)) {
-                if (requestConfiguration.attributeMapping() == NESTED && attributeValue.hasM()) {
+                if (configuration.attributeMapping() == NESTED && attributeValue.hasM()) {
                     nestedItemToMap(attributeValueMap, attributeValue.m(), attributeKey, ignoreNulls);
                 } else {
                     attributeValueMap.put(attributeKey, attributeValue);
@@ -533,7 +534,7 @@ public Map itemToMap(T item, boolean ignoreNulls,
         });
 
         indexedFlattenedMappers.forEach((name, flattenedMapper) -> {
-            attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls, requestConfiguration));
+            attributeValueMap.putAll(flattenedMapper.itemToMap(item, ignoreNulls, configuration));
         });
 
         return unmodifiableMap(attributeValueMap);
@@ -541,7 +542,7 @@ public Map itemToMap(T item, boolean ignoreNulls,
 
     @Override
     public Map itemToMap(T item, boolean ignoreNulls) {
-        return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        return itemToMap(item, getMappingConfiguration(ignoreNulls, SHALLOW));
     }
 
     private void nestedItemToMap(Map resultAttributeValueMap,
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java
index 73f1f82459fe..6dc6b2d4f211 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchema.java
@@ -18,7 +18,6 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
-import java.util.Map;
 import java.util.function.BiConsumer;
 import java.util.function.Consumer;
 import java.util.function.Function;
@@ -32,8 +31,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.DefaultAttributeConverterProvider;
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedType;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
-import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 /**
  * Implementation of {@link TableSchema} that builds a schema based on directly declared attributes and methods to
@@ -90,11 +87,6 @@ public static  Builder builder(EnhancedType itemType) {
         return new Builder<>(itemType);
     }
 
-    @Override
-    public Map itemToMap(T item, boolean ignoreNulls) {
-        return itemToMap(item, ignoreNulls, new DynamoDBEnhancedRequestConfiguration(AttributeMapping.SHALLOW));
-    }
-
     /**
      * Builder for a {@link StaticTableSchema}
      * @param  The data item type that the {@link StaticTableSchema} this builder will build is to map to.
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java
index 4cd999d35ca9..627cba9b304e 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/WrappedTableSchema.java
@@ -15,6 +15,9 @@
 
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -24,7 +27,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedType;
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 /**
@@ -64,9 +66,13 @@ public T mapToItem(Map attributeMap, boolean preserveEmp
     }
 
     @Override
-    public Map itemToMap(T item, boolean ignoreNulls,
-                                                 DynamoDBEnhancedRequestConfiguration requestConfiguration) {
-        return this.delegateTableSchema.itemToMap(item, ignoreNulls, requestConfiguration);
+    public Map itemToMap(T item, boolean ignoreNulls) {
+        return this.delegateTableSchema.itemToMap(item, getMappingConfiguration(ignoreNulls, SHALLOW));
+    }
+
+    @Override
+    public Map itemToMap(T item, MappingConfiguration configuration) {
+        return this.delegateTableSchema.itemToMap(item, configuration);
     }
 
     @Override
diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java
index da4b62db0886..af12f7ec5dc2 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.java
@@ -21,16 +21,16 @@
 import java.lang.annotation.Target;
 import software.amazon.awssdk.annotations.SdkPublicApi;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 
 /**
- * Specifies that when calling {@link TableSchema#itemToMap(Object, boolean, DynamoDBEnhancedRequestConfiguration)}, a separate
+ * Specifies that when calling {@link TableSchema#itemToMap(Object, MappingConfiguration)}, a separate
  * DynamoDB object
  * that is stored in the current object should ignore the attributes with null values. Note that if this annotation
  * is absent, NULL attributes will be created.
  *
  * 

- * Example using {@link DynamoDbIgnoreNulls}:d + * Example using {@link DynamoDbIgnoreNulls} *

  * 
  * @DynamoDbBean
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java
index dc0d922d80a2..8eede432dd34 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/document/DocumentTableSchemaTest.java
@@ -20,7 +20,6 @@
 import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
 import static software.amazon.awssdk.enhanced.dynamodb.AttributeConverterProvider.defaultProvider;
 import static software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocumentTestData.testDataInstance;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Arrays;
 import java.util.Collections;
@@ -36,7 +35,10 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.converters.document.CustomAttributeForDocumentConverterProvider;
 import software.amazon.awssdk.enhanced.dynamodb.converters.document.CustomClassForDocumentAPI;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.document.DocumentTableSchema;
+import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocument;
+import software.amazon.awssdk.enhanced.dynamodb.document.EnhancedDocumentTestData;
+import software.amazon.awssdk.enhanced.dynamodb.document.TestData;
 import software.amazon.awssdk.enhanced.dynamodb.internal.converter.ChainConverterProvider;
 import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.StaticKeyAttributeMetadata;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -123,8 +125,7 @@ void validate_DocumentTableSchemaItemToMap(TestData testData) {
         DocumentTableSchema documentTableSchema = DocumentTableSchema.builder().build();
 
         Assertions.assertThat(
-            documentTableSchema.itemToMap(testData.getEnhancedDocument(), false,
-                                          new DynamoDBEnhancedRequestConfiguration(SHALLOW))).isEqualTo(testData.getDdbItemMap());
+            documentTableSchema.itemToMap(testData.getEnhancedDocument(), false)).isEqualTo(testData.getDdbItemMap());
     }
 
     @ParameterizedTest
@@ -233,6 +234,6 @@ void validate_DocumentTableSchema_WithCustomIntegerAttributeProvider() {
                                                                              CustomAttributeForDocumentConverterProvider.create()))
                                                                      .build();
         Assertions.assertThat(
-            documentTableSchema.itemToMap(numberDocument, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW))).isEqualTo(resultMap);
+            documentTableSchema.itemToMap(numberDocument, true)).isEqualTo(resultMap);
     }
 }
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java
index 3b35b16b6ebe..6ee6cf915d74 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AtomicCounterExtensionTest.java
@@ -16,7 +16,6 @@
 package software.amazon.awssdk.enhanced.dynamodb.extensions;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.atomicCounter;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey;
 
@@ -28,7 +27,6 @@
 import org.junit.Test;
 import software.amazon.awssdk.enhanced.dynamodb.OperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.OperationName;
@@ -79,7 +77,7 @@ public void beforeWrite_updateItemOperation_hasCounters_createsUpdateExpression(
         AtomicCounterItem atomicCounterItem = new AtomicCounterItem();
         atomicCounterItem.setId(RECORD_ID);
 
-        Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true);
         assertThat(items).hasSize(1);
 
         WriteModification result =
@@ -108,7 +106,7 @@ public void beforeWrite_updateItemOperation_noCounters_noChanges() {
         item.setId(RECORD_ID);
         item.setNumberAttribute(4L);
 
-        Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true);
         assertThat(items).hasSize(2);
 
         WriteModification result =
@@ -127,7 +125,7 @@ public void beforeWrite_updateItemOperation_hasCountersInItem_createsUpdateExpre
         atomicCounterItem.setId(RECORD_ID);
         atomicCounterItem.setCustomCounter(255L);
 
-        Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true);
         assertThat(items).hasSize(2);
 
         WriteModification result =
@@ -155,7 +153,7 @@ public void beforeWrite_putItemOperation_hasCounters_createsItemTransform() {
         AtomicCounterItem atomicCounterItem = new AtomicCounterItem();
         atomicCounterItem.setId(RECORD_ID);
 
-        Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map items = ITEM_MAPPER.itemToMap(atomicCounterItem, true);
         assertThat(items).hasSize(1);
 
         WriteModification result =
@@ -176,7 +174,7 @@ public void beforeWrite_putItemOperation_noCounters_noChanges() {
         item.setId(RECORD_ID);
         item.setNumberAttribute(4L);
 
-        Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map items = SIMPLE_ITEM_MAPPER.itemToMap(item, true);
         assertThat(items).hasSize(2);
 
         WriteModification result =
@@ -194,7 +192,7 @@ public void beforeWrite_putItemOperation_noCounters_noChanges() {
     public void beforeRead_doesNotTransformObject() {
         AtomicCounterItem atomicCounterItem = new AtomicCounterItem();
         atomicCounterItem.setId(RECORD_ID);
-        Map fakeItemMap = ITEM_MAPPER.itemToMap(atomicCounterItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = ITEM_MAPPER.itemToMap(atomicCounterItem, true);
 
         ReadModification result =
             atomicCounterExtension.afterRead(DefaultDynamoDbExtensionContext
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java
index 89f2a9d01fe6..cc69f503d50f 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/AutoGeneratedUuidExtensionTest.java
@@ -17,7 +17,6 @@
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey;
 
 import java.util.Map;
@@ -27,7 +26,6 @@
 import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.enhanced.dynamodb.OperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.OperationName;
@@ -74,7 +72,7 @@ public void beforeWrite_updateItemOperation_hasUuidInItem_doesNotCreateUpdateExp
         String uuidAttribute = String.valueOf(UUID.randomUUID());
         SimpleItem.setUuidAttribute(uuidAttribute);
 
-        Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true);
         assertThat(items).hasSize(2);
 
         WriteModification result =
@@ -97,7 +95,7 @@ public void beforeWrite_updateItemOperation_hasNoUuidInItem_doesNotCreatesUpdate
         ItemWithUuid SimpleItem = new ItemWithUuid();
         SimpleItem.setId(RECORD_ID);
 
-        Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true, new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map items = ITEM_WITH_UUID_MAPPER.itemToMap(SimpleItem, true);
         assertThat(items).hasSize(1);
 
         WriteModification result =
@@ -119,7 +117,7 @@ public void beforeWrite_updateItemOperation_UuidNotPresent_newUuidCreated() {
         ItemWithUuid item = new ItemWithUuid();
         item.setId(RECORD_ID);
 
-        Map items = ITEM_WITH_UUID_MAPPER.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map items = ITEM_WITH_UUID_MAPPER.itemToMap(item, true);
         assertThat(items).hasSize(1);
 
         WriteModification result =
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java
index 3acdb4579c1a..f68437774203 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/ChainExtensionTest.java
@@ -17,12 +17,13 @@
 
 import static java.util.stream.Collectors.toList;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.nullValue;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isNotNull;
 import static org.mockito.Mockito.when;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -41,7 +42,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.OperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.ChainExtension;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext;
@@ -76,8 +76,7 @@ public class ChainExtensionTest {
     private final List> fakeItems =
         IntStream.range(0, 4)
                  .mapToObj($ -> createUniqueFakeItem())
-                 .map(fakeItem -> FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW)))
+                 .map(fakeItem -> FakeItem.getTableSchema().itemToMap(fakeItem, true))
                  .collect(toList());
 
     @Test
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java
index 8f99f6ef3948..4f61db7487e9 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/extensions/VersionedRecordExtensionTest.java
@@ -20,7 +20,6 @@
 import static org.hamcrest.Matchers.is;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -30,7 +29,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -45,7 +43,7 @@ public class VersionedRecordExtensionTest {
     @Test
     public void beforeRead_doesNotTransformObject() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true);
 
         ReadModification result =
             versionedRecordExtension.afterRead(DefaultDynamoDbExtensionContext
@@ -65,7 +63,7 @@ public void beforeWrite_initialVersion_expressionIsCorrect() {
             versionedRecordExtension.beforeWrite(
                 DefaultDynamoDbExtensionContext
                     .builder()
-                    .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)))
+                    .items(FakeItem.getTableSchema().itemToMap(fakeItem, true))
                     .tableMetadata(FakeItem.getTableMetadata())
                     .operationContext(PRIMARY_CONTEXT).build());
 
@@ -80,13 +78,13 @@ public void beforeWrite_initialVersion_expressionIsCorrect() {
     public void beforeWrite_initialVersion_transformedItemIsCorrect() {
         FakeItem fakeItem = createUniqueFakeItem();
         Map fakeItemWithInitialVersion =
-            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)));
+            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true));
         fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("1").build());
 
         WriteModification result =
             versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext
                                                      .builder()
-                                                     .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)))
+                                                     .items(FakeItem.getTableSchema().itemToMap(fakeItem, true))
                                                      .tableMetadata(FakeItem.getTableMetadata())
                                                      .operationContext(PRIMARY_CONTEXT).build());
 
@@ -98,10 +96,10 @@ public void beforeWrite_initialVersion_transformedItemIsCorrect() {
     public void beforeWrite_initialVersionDueToExplicitNull_transformedItemIsCorrect() {
         FakeItem fakeItem = createUniqueFakeItem();
         Map inputMap =
-            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)));
+            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true));
         inputMap.put("version", AttributeValue.builder().nul(true).build());
         Map fakeItemWithInitialVersion =
-            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)));
+            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true));
         fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("1").build());
 
         WriteModification result =
@@ -122,7 +120,7 @@ public void beforeWrite_existingVersion_expressionIsCorrect() {
         WriteModification result =
             versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext
                                                      .builder()
-                                                     .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)))
+                                                     .items(FakeItem.getTableSchema().itemToMap(fakeItem, true))
                                                      .tableMetadata(FakeItem.getTableMetadata())
                                                      .operationContext(PRIMARY_CONTEXT).build());
 
@@ -140,13 +138,13 @@ public void beforeWrite_existingVersion_transformedItemIsCorrect() {
         FakeItem fakeItem = createUniqueFakeItem();
         fakeItem.setVersion(13);
         Map fakeItemWithInitialVersion =
-            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)));
+            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true));
         fakeItemWithInitialVersion.put("version", AttributeValue.builder().n("14").build());
 
         WriteModification result =
             versionedRecordExtension.beforeWrite(DefaultDynamoDbExtensionContext
                                                      .builder()
-                                                     .items(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)))
+                                                     .items(FakeItem.getTableSchema().itemToMap(fakeItem, true))
                                                      .tableMetadata(FakeItem.getTableMetadata())
                                                      .operationContext(PRIMARY_CONTEXT).build());
 
@@ -157,7 +155,7 @@ public void beforeWrite_existingVersion_transformedItemIsCorrect() {
     public void beforeWrite_returnsNoOpModification_ifVersionAttributeNotDefined() {
         FakeItemWithSort fakeItemWithSort = createUniqueFakeItemWithSort();
         Map itemMap =
-            new HashMap<>(FakeItemWithSort.getTableSchema().itemToMap(fakeItemWithSort, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)));
+            new HashMap<>(FakeItemWithSort.getTableSchema().itemToMap(fakeItemWithSort, true));
 
         WriteModification writeModification = versionedRecordExtension.beforeWrite( DefaultDynamoDbExtensionContext.builder()
                                                                                                                    .items(itemMap)
@@ -171,7 +169,7 @@ public void beforeWrite_returnsNoOpModification_ifVersionAttributeNotDefined() {
     public void beforeWrite_throwsIllegalArgumentException_ifVersionAttributeIsWrongType() {
         FakeItem fakeItem = createUniqueFakeItem();
         Map fakeItemWIthBadVersion =
-            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)));
+            new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true));
         fakeItemWIthBadVersion.put("version", AttributeValue.builder().s("14").build());
 
         versionedRecordExtension.beforeWrite(
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java
index a897b91f070d..6b20ecb798ef 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedTimestampRecordTest.java
@@ -20,7 +20,6 @@
 import static org.hamcrest.Matchers.is;
 import static software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedTimestampRecordExtension.AttributeTags.autoGeneratedTimestampAttribute;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.updateBehavior;
 
@@ -48,7 +47,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.converters.EpochMillisFormatTestConverter;
 import software.amazon.awssdk.enhanced.dynamodb.converters.TimeFormatUpdateTestConverter;
 import software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedTimestampRecordExtension;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema;
@@ -120,7 +118,7 @@ public class AutoGeneratedTimestampRecordTest extends LocalDynamoDbSyncTestBase
     private final List> fakeItems =
         IntStream.range(0, 4)
                  .mapToObj($ -> createUniqueFakeItem())
-                 .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)))
+                 .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true))
                  .collect(toList());
     private final DynamoDbTable mappedTable;
 
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java
index d297beb20c73..12ca834b0f8c 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/AutoGeneratedUuidRecordTest.java
@@ -18,7 +18,6 @@
 import static java.util.stream.Collectors.toList;
 import static software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedUuidExtension.AttributeTags.autoGeneratedUuidAttribute;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.updateBehavior;
 
@@ -48,7 +47,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.extensions.AutoGeneratedUuidExtension;
 import software.amazon.awssdk.enhanced.dynamodb.extensions.annotations.DynamoDbAutoGeneratedUuid;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.UpdateBehavior;
@@ -126,7 +124,7 @@ public AutoGeneratedUuidRecordTest(String testName, TableSchema recordTa
     private final List> fakeItems =
         IntStream.range(0, 4)
                  .mapToObj($ -> createUniqueFakeItem())
-                 .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)))
+                 .map(fakeItem -> TABLE_SCHEMA.itemToMap(fakeItem, true))
                  .collect(toList());
     private DynamoDbTable mappedTable;
 
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java
index 587ee6dcb9ad..e2919f9769c3 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BeanTableSchemaRecursiveTest.java
@@ -16,7 +16,6 @@
 package software.amazon.awssdk.enhanced.dynamodb.functionaltests;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
 import java.util.Map;
@@ -24,7 +23,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordBean;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordImmutable;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 public class BeanTableSchemaRecursiveTest {
@@ -50,8 +48,7 @@ public void recursiveRecord_document() {
         recursiveRecordBean1.setAttribute(1);
         recursiveRecordBean1.setRecursiveRecordBean(recursiveRecordBean2);
 
-        Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true);
 
         assertThat(itemMap).hasSize(2);
         assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build());
@@ -80,8 +77,7 @@ public void recursiveRecord_list() {
         recursiveRecordBean1.setAttribute(1);
         recursiveRecordBean1.setRecursiveRecordList(Collections.singletonList(recursiveRecordBean2));
 
-        Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(recursiveRecordBean1, true);
 
         assertThat(itemMap).hasSize(2);
         assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build());
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java
index 6b8a02ffc3df..532160d99d05 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/ImmutableTableSchemaRecursiveTest.java
@@ -16,7 +16,6 @@
 package software.amazon.awssdk.enhanced.dynamodb.functionaltests;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
 import java.util.Map;
@@ -24,7 +23,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordBean;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecursiveRecordImmutable;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 public class ImmutableTableSchemaRecursiveTest {
@@ -52,8 +50,7 @@ public void recursiveRecord_document() {
                                     .setRecursiveRecordImmutable(recursiveRecordImmutable2)
                                     .build();
 
-        Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true);
 
         assertThat(itemMap).hasSize(2);
         assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build());
@@ -86,8 +83,7 @@ public void recursiveRecord_list() {
                                     .setRecursiveRecordList(Collections.singletonList(recursiveRecordImmutable2))
                                     .build();
 
-        Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(recursiveRecordImmutable1, true);
 
         assertThat(itemMap).hasSize(2);
         assertThat(itemMap).containsEntry("attribute", AttributeValue.builder().n("1").build());
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java
index 69cb84fa53bb..7477047d83b8 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/UpdateBehaviorTest.java
@@ -2,6 +2,7 @@
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
@@ -20,7 +21,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FlattenRecord;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.NestedRecordWithUpdateBehavior;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.RecordWithUpdateBehaviors;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.client.ExtensionResolver;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
@@ -250,7 +251,7 @@ public void when_updatingNestedObjectWithMultipleLevels_existingInformationIsPre
     }
 
     @Test
-    public void when_updatingNestedObjectWithSingleLevelFlattened_existingInformationIsPreserved1() {
+    public void when_updatingNestedObjectWithSingleLevelFlattened_existingInformationIsPreserved() {
         TableSchema tableSchema = TableSchema.fromClass(FlattenRecord.class);
 
         NestedRecordWithUpdateBehavior nestedRecord = createNestedWithDefaults("id123", 10L);
@@ -264,11 +265,9 @@ public void when_updatingNestedObjectWithSingleLevelFlattened_existingInformatio
         flattenRecord.setId("id456");
 
 
-        Map itemMapShallow = tableSchema.itemToMap(flattenRecord, true,
-                                                                           new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMapShallow = tableSchema.itemToMap(flattenRecord, getMappingConfiguration(true, SHALLOW));
 
-        Map itemMapNested = tableSchema.itemToMap(flattenRecord, true,
-                                                                          new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map itemMapNested = tableSchema.itemToMap(flattenRecord, getMappingConfiguration(true, NESTED));
 
 
         assertThat(itemMapShallow).hasSize(2);
@@ -276,7 +275,7 @@ public void when_updatingNestedObjectWithSingleLevelFlattened_existingInformatio
     }
 
     @Test
-    public void when_updatingNestedObjectWithMultipleLevelsFlattened_existingInformationIsPreserved1() {
+    public void when_updatingNestedObjectWithMultipleLevelsFlattened_existingInformationIsPreserved() {
         TableSchema tableSchema = TableSchema.fromClass(FlattenRecord.class);
 
         NestedRecordWithUpdateBehavior outerNestedRecord = createNestedWithDefaults("id123", 10L);
@@ -292,11 +291,9 @@ public void when_updatingNestedObjectWithMultipleLevelsFlattened_existingInforma
         flattenRecord.setId("id456");
 
 
-        Map itemMapShallow = tableSchema.itemToMap(flattenRecord, true,
-                                                                           new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMapShallow = tableSchema.itemToMap(flattenRecord, getMappingConfiguration(true, SHALLOW));
 
-        Map itemMapNested = tableSchema.itemToMap(flattenRecord, true,
-                                                                          new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map itemMapNested = tableSchema.itemToMap(flattenRecord, getMappingConfiguration(true, NESTED));
 
 
         assertThat(itemMapShallow).hasSize(2);
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java
index e3aca1ce1f75..5365975dd5bb 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/DefaultDocumentTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Map;
@@ -38,6 +39,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.DefaultOperationContext;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
@@ -62,8 +64,8 @@ private DynamoDbTable createMappedTable(DynamoDbEnhancedClientExtensio
     @Test
     public void noExtension_mapsToItem() {
         FakeItem fakeItem = FakeItem.createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
         Document defaultDocument = DefaultDocument.create(fakeItemMap);
 
         assertThat(defaultDocument.getItem(createMappedTable(null)), is(fakeItem));
@@ -73,10 +75,10 @@ public void noExtension_mapsToItem() {
     public void extension_mapsToItem() {
         FakeItem fakeItem = FakeItem.createUniqueFakeItem();
         FakeItem fakeItem2 = FakeItem.createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
-        Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true,
-                                                                                       new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
+        Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, getMappingConfiguration(true,
+                                                                                                                          SHALLOW));
         when(mockDynamoDbEnhancedClientExtension.afterRead(any(DynamoDbExtensionContext.AfterRead.class)))
             .thenReturn(ReadModification.builder().transformedItem(fakeItemMap2).build());
 
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java
index ce8bbcb15097..a6ceb1f1d141 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/immutable/MetaTableSchemaTest.java
@@ -20,6 +20,7 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collection;
@@ -38,9 +39,8 @@
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.mapper.MetaTableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 @RunWith(MockitoJUnitRunner.class)
@@ -76,18 +76,20 @@ public void mapToItem_notInitialized() {
     @Test
     public void itemToMap_ignoreNulls() {
         metaTableSchema.initialize(mockTableSchema);
-        when(mockTableSchema.itemToMap(any(FakeItem.class), any(boolean.class), any(DynamoDBEnhancedRequestConfiguration.class))).thenReturn(fakeMap);
 
-        DynamoDBEnhancedRequestConfiguration shallowRequestConfigurationParameter = new DynamoDBEnhancedRequestConfiguration(SHALLOW);
-        assertThat(metaTableSchema.itemToMap(fakeItem, true, shallowRequestConfigurationParameter)).isSameAs(fakeMap);
-        verify(mockTableSchema).itemToMap(fakeItem, true, shallowRequestConfigurationParameter);
-        assertThat(metaTableSchema.itemToMap(fakeItem, false, shallowRequestConfigurationParameter)).isSameAs(fakeMap);
-        verify(mockTableSchema).itemToMap(fakeItem, false, shallowRequestConfigurationParameter);
+        MappingConfiguration ignoreNullsConfiguration = getMappingConfiguration(true,SHALLOW);
+        MappingConfiguration ignoreNullsFalseConfiguration = getMappingConfiguration(false,SHALLOW);
+        when(mockTableSchema.itemToMap(any(FakeItem.class), any(MappingConfiguration.class))).thenReturn(fakeMap);
+
+        assertThat(metaTableSchema.itemToMap(fakeItem, ignoreNullsConfiguration)).isSameAs(fakeMap);
+        verify(mockTableSchema).itemToMap(fakeItem, ignoreNullsConfiguration);
+        assertThat(metaTableSchema.itemToMap(fakeItem, ignoreNullsFalseConfiguration)).isSameAs(fakeMap);
+        verify(mockTableSchema).itemToMap(fakeItem, ignoreNullsFalseConfiguration);
     }
 
     @Test
     public void itemToMap_ignoreNulls_notInitialized() {
-        assertUninitialized(t -> t.itemToMap(fakeItem, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)));
+        assertUninitialized(t -> t.itemToMap(fakeItem, true));
     }
 
     @Test
@@ -95,7 +97,7 @@ public void itemToMap_attributes() {
         Collection attributes = Collections.singletonList("test-attribute");
 
         metaTableSchema.initialize(mockTableSchema);
-        when(mockTableSchema.itemToMap(any(FakeItem.class), any())).thenReturn(fakeMap);
+        when(mockTableSchema.itemToMap(any(FakeItem.class), any(Collection.class))).thenReturn(fakeMap);
 
         assertThat(metaTableSchema.itemToMap(fakeItem, attributes)).isSameAs(fakeMap);
         verify(mockTableSchema).itemToMap(fakeItem, attributes);
@@ -103,7 +105,7 @@ public void itemToMap_attributes() {
 
     @Test
     public void itemToMap_attributes_notInitialized() {
-        assertUninitialized(t -> t.itemToMap(fakeItem, null));
+        assertUninitialized(t -> t.itemToMap(fakeItem, (Collection) null));
     }
 
     @Test
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java
index 441fe3f90c86..6185e1cb85f9 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/DeleteItemOperationTest.java
@@ -31,6 +31,7 @@
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
@@ -50,7 +51,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.model.DeleteItemEnhancedRequest;
 import software.amazon.awssdk.enhanced.dynamodb.model.TransactDeleteItemEnhancedRequest;
@@ -428,10 +429,11 @@ public void generateRequest_withExtension_doesNotModifyKey() {
     public void transformResponse_withExtension_appliesItemModification() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
-        Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false,
-                                                                                          new DynamoDBEnhancedRequestConfiguration(SHALLOW));
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem,
+                                                                                          getMappingConfiguration(false,
+                                                                                                                  SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(false,
+                                                                                                                        SHALLOW));
         DeleteItemOperation deleteItemOperation =
             DeleteItemOperation.create(DeleteItemEnhancedRequest.builder()
                                                                 .key(k -> k.partitionValue(baseFakeItem.getId()))
@@ -460,8 +462,8 @@ public void transformResponse_withExtension_appliesItemModification() {
     @Test
     public void generateTransactWriteItem_basicRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
         DeleteItemOperation deleteItemOperation =
             spy(DeleteItemOperation.create(DeleteItemEnhancedRequest.builder()
                                                                     .key(k -> k.partitionValue(fakeItem.getId()))
@@ -491,8 +493,8 @@ public void generateTransactWriteItem_basicRequest() {
     @Test
     public void generateTransactWriteItem_conditionalRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(false,
+                                                                                                                        SHALLOW));
         DeleteItemOperation deleteItemOperation =
             spy(DeleteItemOperation.create(DeleteItemEnhancedRequest.builder()
                                                                     .key(k -> k.partitionValue(fakeItem.getId()))
@@ -532,8 +534,7 @@ public void generateTransactWriteItem_conditionalRequest() {
     @Test
     public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true, SHALLOW));
         String returnValues = "return-values";
 
         DeleteItemOperation deleteItemOperation =
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java
index 97185c645e29..b6ac33bdf50b 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/GetItemOperationTest.java
@@ -27,6 +27,7 @@
 import static org.mockito.Mockito.when;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.HashMap;
@@ -45,7 +46,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.model.GetItemEnhancedRequest;
 import software.amazon.awssdk.enhanced.dynamodb.model.GetItemEnhancedResponse;
@@ -247,10 +248,11 @@ public void generateRequest_withExtension_doesNotModifyKey() {
     public void transformResponse_withExtension_appliesItemModification() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
-        Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false,
-                                                                                          new DynamoDBEnhancedRequestConfiguration(SHALLOW));
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map baseFakeItemMap = FakeItem.getTableSchema().itemToMap(baseFakeItem,
+                                                                                          getMappingConfiguration(false,
+                                                                                                                  SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(false,
+                                                                                                                        SHALLOW));
         GetItemOperation getItemOperation =
             GetItemOperation.create(GetItemEnhancedRequest.builder().key(k -> k.partitionValue(baseFakeItem.getId())).build());
         GetItemResponse response = GetItemResponse.builder()
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java
index 81a0c6488af4..b89ca0bf24af 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/PutItemOperationTest.java
@@ -28,6 +28,7 @@
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
@@ -46,7 +47,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.model.PutItemEnhancedRequest;
 import software.amazon.awssdk.enhanced.dynamodb.model.TransactPutItemEnhancedRequest;
@@ -476,10 +477,10 @@ public void transformResponse_doesNotBlowUp() {
     public void generateRequest_withExtension_modifiesItemToPut() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
-        Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
+        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                    SHALLOW));
         when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class)))
             .thenReturn(WriteModification.builder().transformedItem(fakeMap).build());
         PutItemOperation putItemOperation = PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class)
@@ -504,8 +505,8 @@ public void generateRequest_withExtension_modifiesItemToPut() {
     public void generateRequest_withExtension_singleCondition() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                    SHALLOW));
         Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build();
         when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class)))
             .thenReturn(WriteModification.builder().additionalConditionalExpression(condition).build());
@@ -540,8 +541,8 @@ public void generateRequest_withExtension_noModifications() {
     @Test
     public void generateTransactWriteItem_basicRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
         PutItemOperation putItemOperation = spy(PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class)
                                                                                                         .item(fakeItem)
                                                                                                         .build()));
@@ -570,8 +571,8 @@ public void generateTransactWriteItem_basicRequest() {
     @Test
     public void generateTransactWriteItem_conditionalRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
         PutItemOperation putItemOperation = spy(PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class)
                                                                                                         .item(fakeItem)
                                                                                                         .build()));
@@ -610,8 +611,8 @@ public void generateTransactWriteItem_conditionalRequest() {
     @Test
     public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
         String returnValues = "return-values";
 
         PutItemOperation putItemOperation =
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java
index dab8c1977726..c2349e75d186 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/TransactWriteItemsOperationTest.java
@@ -23,6 +23,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Map;
@@ -35,7 +36,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension;
 import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.model.TransactWriteItemsEnhancedRequest;
 import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -50,10 +51,12 @@ public class TransactWriteItemsOperationTest {
 
     private final FakeItem fakeItem1 = FakeItem.createUniqueFakeItem();
     private final FakeItem fakeItem2 = FakeItem.createUniqueFakeItem();
-    private final Map fakeItemMap1 = FakeItem.getTableSchema().itemToMap(fakeItem1, true,
-                                                                                                 new DynamoDBEnhancedRequestConfiguration(SHALLOW));
-    private final Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2, true,
-                                                                                                 new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+    private final Map fakeItemMap1 = FakeItem.getTableSchema().itemToMap(fakeItem1,
+                                                                                                 getMappingConfiguration(true,
+                                                                                                                         SHALLOW));
+    private final Map fakeItemMap2 = FakeItem.getTableSchema().itemToMap(fakeItem2,
+                                                                                                 getMappingConfiguration(true,
+                                                                                                                         SHALLOW));
 
     @Mock
     private DynamoDbEnhancedClientExtension mockDynamoDbEnhancedClientExtension;
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java
index e5747437d3b6..961744f7f4d6 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTest.java
@@ -31,7 +31,9 @@
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort.createUniqueFakeItemWithSort;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -53,7 +55,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.extensions.WriteModification;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.extensions.DefaultDynamoDbExtensionContext;
 import software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedRequest;
 import software.amazon.awssdk.enhanced.dynamodb.update.DeleteAction;
@@ -284,10 +286,10 @@ public void generateRequest_withExtension_modifiesKeyPortionOfItem() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
 
-        Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, getMappingConfiguration(false,
+                                                                                                                        NESTED));
+        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(false,
+                                                                                                                    NESTED));
         Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id"));
 
         when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class)))
@@ -309,10 +311,8 @@ public void generateRequest_withFlattenedMap_withNestedAttributes() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
 
-        Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, false,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, false,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map baseMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, getMappingConfiguration(false, NESTED));
+        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(false, NESTED));
         Map keyMap = FakeItem.getTableSchema().itemToMap(fakeItem, singletonList("id"));
 
         when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class)))
@@ -332,8 +332,9 @@ public void generateRequest_withFlattenedMap_withNestedAttributes() {
     @Test
     public void generateRequest_withExtension_transformedItemModifiesUpdateExpression() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                                new DynamoDBEnhancedRequestConfiguration(NESTED)));
+        Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(fakeItem,
+                                                                                                getMappingConfiguration(true,
+                                                                                                                        SHALLOW)));
 
         Map fakeMap = new HashMap<>(baseMap);
         fakeMap.put("subclass_attribute", AttributeValue.builder().s("1").build());
@@ -358,8 +359,8 @@ public void generateRequest_withExtension_transformedItemModifiesUpdateExpressio
     public void generateRequest_withExtensions_singleCondition() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                    SHALLOW));
         Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build();
         when(mockDynamoDbEnhancedClientExtension.beforeWrite(any(DynamoDbExtensionContext.BeforeWrite.class)))
             .thenReturn(WriteModification.builder().additionalConditionalExpression(condition).build());
@@ -401,8 +402,8 @@ public void generateRequest_withExtensions_singleUpdateExpression() {
     public void generateRequest_withExtensions_conditionAndUpdateExpression() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                    SHALLOW));
         Expression condition = Expression.builder().expression("condition").expressionValues(fakeMap).build();
 
         Map deleteActionMap = singletonMap(":val", AttributeValue.builder().s("s").build());
@@ -530,8 +531,9 @@ public void generateRequest_withExtension_noModifications() {
     @Test
     public void generateRequest_withExtension_conditionAndModification() {
         FakeItem baseFakeItem = createUniqueFakeItem();
-        Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(baseFakeItem, true,
-                                                                                                new DynamoDBEnhancedRequestConfiguration(NESTED)));
+        Map baseMap = new HashMap<>(FakeItem.getTableSchema().itemToMap(baseFakeItem,
+                                                                                                getMappingConfiguration(true,
+                                                                                                                        NESTED)));
 
         Map fakeMap = new HashMap<>(baseMap);
         fakeMap.put("subclass_attribute", AttributeValue.builder().s("1").build());
@@ -670,10 +672,10 @@ public void generateRequest_withReturnValues_knownValue_generatesCorrectRequest(
     public void transformResponse_withExtension_returnsCorrectTransformedItem() {
         FakeItem baseFakeItem = createUniqueFakeItem();
         FakeItem fakeItem = createUniqueFakeItem();
-        Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(NESTED));
-        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem,
+                                                                                      getMappingConfiguration(true, NESTED));
+        Map fakeMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                    NESTED));
 
         when(mockDynamoDbEnhancedClientExtension.afterRead(any(DynamoDbExtensionContext.AfterRead.class))).thenReturn(
             ReadModification.builder().transformedItem(fakeMap).build());
@@ -690,8 +692,8 @@ public void transformResponse_withNoOpExtension_returnsCorrectItem() {
             .thenReturn(ReadModification.builder().build());
 
         FakeItem baseFakeItem = createUniqueFakeItem();
-        Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map baseFakeMap = FakeItem.getTableSchema().itemToMap(baseFakeItem,
+                                                                                      getMappingConfiguration(true, NESTED));
 
         FakeItem resultItem = transformResponse(baseFakeItem);
 
@@ -788,7 +790,7 @@ private FakeItem transformResponse(FakeItem item) {
         UpdateItemOperation updateItemOperation =
             UpdateItemOperation.create(requestFakeItem(item, b -> b.ignoreNulls(true)));
 
-        Map itemMap = FakeItem.getTableSchema().itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(NESTED));
+        Map itemMap = FakeItem.getTableSchema().itemToMap(item, getMappingConfiguration(true, NESTED));
         return updateItemOperation.transformResponse(UpdateItemResponse.builder().attributes(itemMap).build(),
                                                      FakeItem.getTableSchema(),
                                                      PRIMARY_CONTEXT,
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java
index 1c6ca2eafb42..50d112c935a9 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/UpdateItemOperationTransactTest.java
@@ -23,6 +23,8 @@
 import static org.mockito.Mockito.verify;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Collections;
@@ -36,7 +38,7 @@
 import software.amazon.awssdk.enhanced.dynamodb.OperationContext;
 import software.amazon.awssdk.enhanced.dynamodb.TableMetadata;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.MappingConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.model.TransactUpdateItemEnhancedRequest;
 import software.amazon.awssdk.enhanced.dynamodb.model.UpdateItemEnhancedRequest;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -55,8 +57,8 @@ public class UpdateItemOperationTransactTest {
     @Test
     public void generateTransactWriteItem_basicRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
         UpdateItemOperation updateItemOperation =
             spy(UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).build()));
         OperationContext context = DefaultOperationContext.create(TABLE_NAME, TableMetadata.primaryIndexName());
@@ -92,8 +94,7 @@ public void generateTransactWriteItem_basicRequest() {
     @Test
     public void generateTransactWriteItem_conditionalRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true, SHALLOW));
         UpdateItemOperation updateItemOperation =
             spy(UpdateItemOperation.create(UpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).build()));
         OperationContext context = DefaultOperationContext.create(TABLE_NAME, TableMetadata.primaryIndexName());
@@ -132,8 +133,8 @@ public void generateTransactWriteItem_conditionalRequest() {
     @Test
     public void generateTransactWriteItem_returnValuesOnConditionCheckFailure_generatesCorrectRequest() {
         FakeItem fakeItem = createUniqueFakeItem();
-        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, getMappingConfiguration(true,
+                                                                                                                        SHALLOW));
         String returnValues = "return-values";
 
         UpdateItemOperation updateItemOperation =
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java
index 70976788997b..c1c61712243e 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java
@@ -27,6 +27,7 @@
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.nio.charset.StandardCharsets;
@@ -44,7 +45,6 @@
 import software.amazon.awssdk.core.SdkBytes;
 import software.amazon.awssdk.enhanced.dynamodb.EnhancedType;
 import software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractBean;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractImmutable;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AttributeConverterBean;
@@ -136,8 +136,8 @@ public void dynamoDbIgnore_propertyIsIgnored() {
         ignoredAttributeBean.setId("id-value");
         ignoredAttributeBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, getMappingConfiguration(false,
+                                                                                                                      SHALLOW));
 
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -150,8 +150,7 @@ public void transient_propertyIsIgnored() {
         ignoredAttributeBean.setId("id-value");
         ignoredAttributeBean.setInteger2Attribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, getMappingConfiguration(false, SHALLOW));
 
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -167,8 +166,8 @@ public void setterAnnotations_alsoWork() {
 
         assertThat(beanTableSchema.tableMetadata().primaryPartitionKey(), is("id"));
 
-        Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, getMappingConfiguration(false,
+                                                                                                                     SHALLOW));
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
     }
@@ -190,8 +189,8 @@ public void dynamoDbFlatten_correctlyFlattensBeanAttributes() {
         flattenedBeanBean.setAttribute1("one");
         flattenedBeanBean.setAbstractBean(abstractBean);
 
-        Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, getMappingConfiguration(false,
+                                                                                                                   SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -206,8 +205,7 @@ public void dynamoDbPreserveEmptyObject_shouldInitializeAsEmptyClass() {
 
         bean.setInnerBean(innerPreserveEmptyBean);
 
-        Map itemMap = beanTableSchema.itemToMap(bean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(bean, getMappingConfiguration(true, SHALLOW));
         NestedBean nestedBean = beanTableSchema.mapToItem(itemMap);
         assertThat(nestedBean.getInnerBean(), is(innerPreserveEmptyBean));
     }
@@ -220,8 +218,7 @@ public void dynamoDbIgnoreNulls_shouldOmitNulls() {
         bean.setInnerBean1(new AbstractBean());
         bean.setInnerBean2(new AbstractBean());
 
-        Map itemMap = beanTableSchema.itemToMap(bean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(bean, getMappingConfiguration(true, SHALLOW));
         AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().m(new HashMap<>()).build();
 
         assertThat(itemMap.size(), is(2));
@@ -237,8 +234,7 @@ public void dynamoDbIgnoreNulls_onList_shouldOmitNulls() {
         bean.setInnerBeanList1(Collections.singletonList(new AbstractBean()));
         bean.setInnerBeanList2(Collections.singletonList(new AbstractBean()));
 
-        Map itemMap = beanTableSchema.itemToMap(bean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(bean, getMappingConfiguration(true, SHALLOW));
         AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().l(l -> l.m(emptyMap())).build();
         AttributeValue expectedMapForInnerBean2 = AttributeValue.builder()
                                                                 .l(l -> l.m(singletonMap("attribute2", nullAttributeValue())))
@@ -258,8 +254,7 @@ public void dynamoDbFlatten_correctlyFlattensImmutableAttributes() {
         flattenedImmutableBean.setAttribute1("one");
         flattenedImmutableBean.setAbstractImmutable(abstractImmutable);
 
-        Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, getMappingConfiguration(false, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -280,8 +275,7 @@ public void documentBean_correctlyMapsBeanAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -308,8 +302,7 @@ public void documentBean_list_correctlyMapsBeanAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -343,8 +336,7 @@ public void documentBean_map_correctlyMapsBeanAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -364,8 +356,7 @@ public void documentBean_correctlyMapsImmutableAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -390,8 +381,7 @@ public void documentBean_list_correctlyMapsImmutableAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -423,8 +413,7 @@ public void documentBean_map_correctlyMapsImmutableAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -445,8 +434,7 @@ public void parameterizedDocumentBean_correctlyMapsAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -473,8 +461,7 @@ public void parameterizedDocumentBean_list_correctlyMapsAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -508,8 +495,7 @@ public void parameterizedDocumentBean_map_correctlyMapsAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -524,8 +510,7 @@ public void extendedBean_correctlyExtendsAttributes() {
         extendedBean.setAttribute1("one");
         extendedBean.setAttribute2("two");
 
-        Map itemMap = beanTableSchema.itemToMap(extendedBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(extendedBean, getMappingConfiguration(false, SHALLOW));
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -543,8 +528,7 @@ public void itemToMap_nullAttribute_ignoreNullsTrue() {
         SimpleBean simpleBean = new SimpleBean();
         simpleBean.setId("id-value");
 
-        Map itemMap = beanTableSchema.itemToMap(simpleBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(simpleBean, getMappingConfiguration(true, SHALLOW));
 
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -556,8 +540,7 @@ public void itemToMap_nullAttribute_ignoreNullsFalse() {
         SimpleBean simpleBean = new SimpleBean();
         simpleBean.setId("id-value");
 
-        Map itemMap = beanTableSchema.itemToMap(simpleBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(simpleBean, getMappingConfiguration(false, SHALLOW));
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -571,8 +554,7 @@ public void itemToMap_nonNullAttribute() {
         simpleBean.setId("id-value");
         simpleBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(simpleBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(simpleBean, getMappingConfiguration(false, SHALLOW));
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -625,8 +607,7 @@ public void enumBean_singleEnum() {
         enumBean.setId("id-value");
         enumBean.setTestEnum(EnumBean.TestEnum.ONE);
 
-        Map itemMap = beanTableSchema.itemToMap(enumBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(enumBean, getMappingConfiguration(true, SHALLOW));
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -643,8 +624,7 @@ public void enumBean_listEnum() {
         enumBean.setId("id-value");
         enumBean.setTestEnumList(Arrays.asList(EnumBean.TestEnum.ONE, EnumBean.TestEnum.TWO));
 
-        Map itemMap = beanTableSchema.itemToMap(enumBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(enumBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .l(stringValue("ONE"),
@@ -665,8 +645,7 @@ public void listBean_stringList() {
         listBean.setId("id-value");
         listBean.setStringList(Arrays.asList("one", "two", "three"));
 
-        Map itemMap = beanTableSchema.itemToMap(listBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(listBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .l(stringValue("one"),
@@ -689,8 +668,7 @@ public void listBean_stringListList() {
         listBean.setId("id-value");
         listBean.setStringListList(Arrays.asList(Arrays.asList("one", "two"), Arrays.asList("three", "four")));
 
-        Map itemMap = beanTableSchema.itemToMap(listBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(listBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue list1 = AttributeValue.builder().l(stringValue("one"), stringValue("two")).build();
         AttributeValue list2 = AttributeValue.builder().l(stringValue("three"), stringValue("four")).build();
@@ -717,8 +695,7 @@ public void setBean_stringSet() {
         stringSet.add("three");
         setBean.setStringSet(stringSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ss("one", "two", "three")
@@ -743,8 +720,7 @@ public void setBean_integerSet() {
         integerSet.add(3);
         setBean.setIntegerSet(integerSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -769,8 +745,7 @@ public void setBean_longSet() {
         longSet.add(3L);
         setBean.setLongSet(longSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -795,8 +770,7 @@ public void setBean_shortSet() {
         shortSet.add((short)3);
         setBean.setShortSet(shortSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -821,8 +795,7 @@ public void setBean_byteSet() {
         byteSet.add((byte)3);
         setBean.setByteSet(byteSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -847,8 +820,7 @@ public void setBean_doubleSet() {
         doubleSet.add(3.3);
         setBean.setDoubleSet(doubleSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1.1", "2.2", "3.3")
@@ -873,8 +845,7 @@ public void setBean_floatSet() {
         floatSet.add(3.3f);
         setBean.setFloatSet(floatSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1.1", "2.2", "3.3")
@@ -903,8 +874,7 @@ public void setBean_binarySet() {
         binarySet.add(buffer3);
         setBean.setBinarySet(binarySet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .bs(buffer1, buffer2, buffer3)
@@ -930,8 +900,7 @@ public void mapBean_stringStringMap() {
 
         mapBean.setStringMap(testMap);
 
-        Map itemMap = beanTableSchema.itemToMap(mapBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(mapBean, getMappingConfiguration(true, SHALLOW));
 
         Map expectedMap = new HashMap<>();
         expectedMap.put("one", stringValue("two"));
@@ -960,8 +929,7 @@ public void mapBean_mapWithNullValue() {
 
         mapBean.setStringMap(testMap);
 
-        Map itemMap = beanTableSchema.itemToMap(mapBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(mapBean, getMappingConfiguration(true, SHALLOW));
 
         Map expectedMap = new HashMap<>();
         expectedMap.put("one", AttributeValues.nullAttributeValue());
@@ -990,8 +958,7 @@ public void mapBean_nestedStringMap() {
 
         mapBean.setNestedStringMap(testMap);
 
-        Map itemMap = beanTableSchema.itemToMap(mapBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(mapBean, getMappingConfiguration(true, SHALLOW));
 
         Map expectedMap = new HashMap<>();
         expectedMap.put("five", AttributeValue.builder().m(singletonMap("one", stringValue("two"))).build());
@@ -1025,8 +992,7 @@ public void commonTypesBean() {
         commonTypesBean.setFloatAttribute((float) 67.8);
         commonTypesBean.setBinaryAttribute(binaryLiteral);
 
-        Map itemMap = beanTableSchema.itemToMap(commonTypesBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(commonTypesBean, getMappingConfiguration(true, SHALLOW));
 
         assertThat(itemMap.size(), is(9));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -1057,8 +1023,7 @@ public void primitiveTypesBean() {
         primitiveTypesBean.setDoubleAttribute(56.7);
         primitiveTypesBean.setFloatAttribute((float) 67.8);
 
-        Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, true,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, getMappingConfiguration(true, SHALLOW));
 
         assertThat(itemMap.size(), is(8));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -1118,8 +1083,7 @@ public void usesCustomAttributeConverter() {
         converterBean.setIntegerAttribute(123);
         converterBean.setAttributeItem(attributeItem);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
 
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -1145,8 +1109,7 @@ public void usesCustomAttributeConverterProvider() {
         converterBean.setId("id-value");
         converterBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value-custom")));
@@ -1166,8 +1129,7 @@ public void usesCustomAttributeConverterProviders() {
         converterBean.setId("id-value");
         converterBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value-custom")));
@@ -1193,8 +1155,7 @@ public void emptyConverterProviderList_correct_whenAttributeConvertersAreSupplie
         converterBean.setId("id-value");
         converterBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, false,
-                                                                        new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value-custom")));
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java
index 4a1ce52cc469..3e97f4d4b660 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/ImmutableTableSchemaTest.java
@@ -21,13 +21,11 @@
 import static org.hamcrest.Matchers.is;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import org.junit.jupiter.api.Test;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractBean;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.AbstractImmutable;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.DocumentImmutable;
@@ -54,8 +52,7 @@ public void documentImmutable_correctlyMapsBeanAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true,
-                                                                                     new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -85,8 +82,7 @@ public void documentImmutable_list_correctlyMapsBeanAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true,
-                                                                                     new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -122,8 +118,7 @@ public void documentImmutable_map_correctlyMapsBeanAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true,
-                                                                                     new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -144,8 +139,7 @@ public void documentImmutable_correctlyMapsImmutableAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true,
-                                                                                     new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -174,8 +168,7 @@ public void documentImmutable_list_correctlyMapsImmutableAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true,
-                                                                                     new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -209,8 +202,7 @@ public void documentImmutable_map_correctlyMapsImmutableAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true,
-                                                                                     new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = documentImmutableTableSchema.itemToMap(documentImmutable, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -229,8 +221,7 @@ public void dynamoDbFlatten_correctlyFlattensBeanAttributes() {
                                                 .setAbstractBean(abstractBean)
                                                 .build();
 
-        Map itemMap = tableSchema.itemToMap(flattenedBeanImmutable, false,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(flattenedBeanImmutable, false);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -248,8 +239,7 @@ public void dynamoDbFlatten_correctlyFlattensImmutableAttributes() {
                                                      .setAbstractImmutable(abstractImmutable)
                                                      .build();
 
-        Map itemMap = tableSchema.itemToMap(FlattenedImmutableImmutable, false,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(FlattenedImmutableImmutable, false);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -267,8 +257,7 @@ public void dynamodbPreserveEmptyObject_shouldInitializeAsEmptyClass() {
                            .innerBean(abstractImmutable)
                            .build();
 
-        Map itemMap = tableSchema.itemToMap(nestedImmutable, false,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(nestedImmutable, false);
         assertThat(itemMap.size(), is(3));
 
         NestedImmutable result = tableSchema.mapToItem(itemMap);
@@ -286,8 +275,7 @@ public void dynamoDbIgnoreNulls_shouldOmitNulls() {
                                       .innerBean2(AbstractImmutable.builder().build())
                                       .build();
 
-        Map itemMap = tableSchema.itemToMap(nestedImmutable, true,
-                                                                    new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = tableSchema.itemToMap(nestedImmutable, true);
         assertThat(itemMap.size(), is(2));
         AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().m(new HashMap<>()).build();
 
@@ -305,8 +293,7 @@ public void toBuilderImmutable_ignoresToBuilderMethod() {
                                                                   .attribute1("one")
                                                                   .build();
 
-        Map itemMap = toBuilderImmutableTableSchema.itemToMap(toBuilderImmutable, true,
-                                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = toBuilderImmutableTableSchema.itemToMap(toBuilderImmutable, true);
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfigurationTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfigurationTest.java
new file mode 100644
index 000000000000..caf1650b68c8
--- /dev/null
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfigurationTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ *  http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.enhanced.dynamodb.mapper;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class MappingConfigurationTest {
+
+    MappingConfiguration configuration;
+    @BeforeEach
+    public void setup() {
+        configuration = getMappingConfiguration(true, SHALLOW);
+    }
+
+    @Test
+    public void mappingConfigurationTest_verify_initialization_isNotNull() {
+        assertNotNull(configuration);
+    }
+
+    @Test
+    public void mappingConfigurationTest_verify_ToString() {
+        assertEquals("MappingConfiguration(attributeMapping=SHALLOW, ignoreNulls=true)", configuration.toString());
+    }
+
+    @Test
+    public void mappingConfigurationTest_verify_equals() {
+        MappingConfiguration newConfiguration = getMappingConfiguration(true, SHALLOW);
+        assertEquals(newConfiguration, configuration);
+    }
+
+    @Test
+    public void mappingConfigurationTest_verify_hashcode() {
+        MappingConfiguration newConfiguration = getMappingConfiguration(true, SHALLOW);
+        assertEquals(configuration.hashCode(), newConfiguration.hashCode());
+    }
+}
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java
index 17e52bbe9544..818f25cf38f6 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaExtendTest.java
@@ -16,7 +16,6 @@
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey;
 
 import java.util.Collections;
@@ -24,7 +23,6 @@
 import java.util.Map;
 import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 public class StaticImmutableTableSchemaExtendTest {
@@ -68,8 +66,7 @@ public class StaticImmutableTableSchemaExtendTest {
 
     @Test
     public void itemToMap() {
-        Map result = immutableTableSchema.itemToMap(TEST_RECORD, false,
-                                                                            new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map result = immutableTableSchema.itemToMap(TEST_RECORD, false);
 
         assertThat(result).isEqualTo(ITEM_MAP);
     }
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java
index 7187157179b9..117dacd66ac4 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaFlattenTest.java
@@ -16,7 +16,6 @@
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey;
 
 import java.util.Arrays;
@@ -26,7 +25,6 @@
 import java.util.Map;
 import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.enhanced.dynamodb.TableSchema;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
 public class StaticImmutableTableSchemaFlattenTest {
@@ -150,8 +148,7 @@ public class StaticImmutableTableSchemaFlattenTest {
 
     @Test
     public void itemToMap_completeRecord() {
-        Map result = immutableTableSchema.itemToMap(TEST_RECORD, false,
-                                                                            new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map result = immutableTableSchema.itemToMap(TEST_RECORD, false);
 
         assertThat(result).isEqualTo(ITEM_MAP);
     }
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java
index 6d6ae572c9df..da75f3b2bdc5 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java
@@ -30,7 +30,6 @@
 import static software.amazon.awssdk.enhanced.dynamodb.extensions.VersionedRecordExtension.AttributeTags.versionAttribute;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey;
 
 import java.math.BigDecimal;
@@ -60,7 +59,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testimmutables.EntityEnvelopeImmutable;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
@@ -825,8 +823,7 @@ public void getTableMetadata_hasCorrectFields() {
 
     @Test
     public void itemToMap_returnsCorrectMapWithMultipleAttributes() {
-        Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false,
-                                                                                       new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false);
 
         assertThat(attributeMap.size(), is(3));
         assertThat(attributeMap, hasEntry("a_boolean", ATTRIBUTE_VALUE_B));
@@ -837,8 +834,7 @@ public void itemToMap_returnsCorrectMapWithMultipleAttributes() {
     @Test
     public void itemToMap_omitsNullAttributes() {
         FakeMappedItem fakeMappedItemWithNulls = FakeMappedItem.builder().aPrimitiveBoolean(true).build();
-        Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true,
-                                                                                       new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true);
 
         assertThat(attributeMap.size(), is(1));
         assertThat(attributeMap, hasEntry("a_primitive_boolean", ATTRIBUTE_VALUE_B));
@@ -1295,8 +1291,7 @@ public void mapToItem_correctlyConstructsComposedClass() {
     public void mapToItem_preserveEmptyBean_shouldInitializeEmptyBean() {
         FakeItem fakeItem = new FakeItem();
 
-        Map itemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false,
-                                                                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = FakeItem.getTableSchema().itemToMap(fakeItem, false);
 
         FakeItem result = FakeItem.getTableSchema().mapToItem(itemMap, true);
         assertThat(result, is(fakeItem));
@@ -1329,8 +1324,7 @@ public void mapToItem_nestedBeanPreserveEmptyBean_shouldInitializeEmptyBean() {
         FakeItemComposedClass nestedBean = new FakeItemComposedClass();
         FakeItem fakeItem = new FakeItem("1", 1, nestedBean);
 
-        Map itemMap = staticTableSchema.itemToMap(fakeItem, false,
-                                                                          new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = staticTableSchema.itemToMap(fakeItem, false);
 
         FakeItem result = staticTableSchema.mapToItem(itemMap);
         assertThat(result.getComposedObject(), is(nestedBean));
@@ -1355,8 +1349,7 @@ public void itemToMap_nestedBeanIgnoreNulls_shouldOmitNullFields() {
         FakeItemComposedClass nestedBean = new FakeItemComposedClass();
         FakeItem fakeItem = new FakeItem("1", 1, nestedBean);
 
-        Map itemMap = staticTableSchema.itemToMap(fakeItem, true,
-                                                                          new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map itemMap = staticTableSchema.itemToMap(fakeItem, true);
         AttributeValue expectedAttributeValue = AttributeValue.builder().m(new HashMap<>()).build();
         assertThat(itemMap.size(), is(2));
         System.out.println(itemMap);
@@ -1372,8 +1365,7 @@ public void buildAbstractTableSchema() {
                                                                .setter(FakeMappedItem::setAString))
                              .build();
 
-        assertThat(tableSchema.itemToMap(FAKE_ITEM, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap(
-            "aString", stringValue("test-string"))));
+        assertThat(tableSchema.itemToMap(FAKE_ITEM, false), is(singletonMap("aString", stringValue("test-string"))));
 
         exception.expect(UnsupportedOperationException.class);
         exception.expectMessage("abstract");
@@ -1392,7 +1384,7 @@ public void buildAbstractWithFlatten() {
         FakeDocument document = FakeDocument.of("test-string", null);
         FakeMappedItem item = FakeMappedItem.builder().aFakeDocument(document).build();
 
-        assertThat(tableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)),
+        assertThat(tableSchema.itemToMap(item, true),
                    is(singletonMap("documentString", AttributeValue.builder().s("test-string").build())));
     }
 
@@ -1413,7 +1405,7 @@ public void buildAbstractExtends() {
         FakeAbstractSubclass item = new FakeAbstractSubclass();
         item.setAString("test-string");
 
-        assertThat(subclassTableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)),
+        assertThat(subclassTableSchema.itemToMap(item, true),
                    is(singletonMap("aString", AttributeValue.builder().s("test-string").build())));
     }
 
@@ -1496,8 +1488,7 @@ public void usesCustomAttributeConverterProvider() {
                              .build();
 
         Map resultMap =
-            tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false,
-                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+                tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false);
         assertThat(resultMap.get("aString").s(), is(expectedString));
     }
 
@@ -1519,8 +1510,7 @@ public void usesCustomAttributeConverterProviders() {
                              .build();
 
         Map resultMap =
-            tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false,
-                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+                tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false);
         assertThat(resultMap.get("aString").s(), is(expectedString));
     }
 
@@ -1556,7 +1546,7 @@ public void noConverterProvider_handlesCorrectly_whenAttributeConvertersAreSuppl
                         .build();
 
         Map resultMap = tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(),
-                                                                      false, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+                                                                      false);
         assertThat(resultMap.get("aString").s(), is(expectedString));
     }
 
@@ -1577,8 +1567,7 @@ public void builder_canBuildForGenericClassType() {
         Map expectedMap =
             Collections.singletonMap("entity", AttributeValue.fromS("test-value"));
 
-        assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)),
-                   equalTo(expectedMap));
+        assertThat(envelopeTableSchema.itemToMap(testEnvelope, false), equalTo(expectedMap));
         assertThat(envelopeTableSchema.mapToItem(expectedMap).entity(), equalTo("test-value"));
     }
 
@@ -1593,8 +1582,7 @@ private  void verifyAttribute(EnhancedType attributeType,
                                                                          .build();
         Map expectedMap = singletonMap("value", attributeValue);
 
-        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false,
-                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false);
         assertThat(resultMap, is(expectedMap));
 
         FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap);
@@ -1611,8 +1599,7 @@ private  void verifyNullAttribute(EnhancedType attributeType,
                                                                          .build();
         Map expectedMap = singletonMap("value", nullAttributeValue());
 
-        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false,
-                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false);
         assertThat(resultMap, is(expectedMap));
 
         FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap);
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java
index fc7330e9ae23..2989edb6c7be 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java
@@ -29,7 +29,6 @@
 import static org.mockito.Mockito.when;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.math.BigDecimal;
 import java.util.Arrays;
@@ -58,7 +57,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemComposedClass;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItemWithSort;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.mapper.testbeans.EntityEnvelopeBean;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 
@@ -822,8 +820,7 @@ public void getTableMetadata_hasCorrectFields() {
 
     @Test
     public void itemToMap_returnsCorrectMapWithMultipleAttributes() {
-        Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false,
-                                                                                       new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map attributeMap = createSimpleTableSchema().itemToMap(FAKE_ITEM, false);
 
         assertThat(attributeMap.size(), is(3));
         assertThat(attributeMap, hasEntry("a_boolean", ATTRIBUTE_VALUE_B));
@@ -834,8 +831,7 @@ public void itemToMap_returnsCorrectMapWithMultipleAttributes() {
     @Test
     public void itemToMap_omitsNullAttributes() {
         FakeMappedItem fakeMappedItemWithNulls = FakeMappedItem.builder().aPrimitiveBoolean(true).build();
-        Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true,
-                                                                                       new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map attributeMap = createSimpleTableSchema().itemToMap(fakeMappedItemWithNulls, true);
 
         assertThat(attributeMap.size(), is(1));
         assertThat(attributeMap, hasEntry("a_primitive_boolean", ATTRIBUTE_VALUE_B));
@@ -1315,8 +1311,7 @@ public void buildAbstractTableSchema() {
                                                                .setter(FakeMappedItem::setAString))
                              .build();
 
-        assertThat(tableSchema.itemToMap(FAKE_ITEM, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), is(singletonMap(
-            "aString", stringValue("test-string"))));
+        assertThat(tableSchema.itemToMap(FAKE_ITEM, false), is(singletonMap("aString", stringValue("test-string"))));
 
         exception.expect(UnsupportedOperationException.class);
         exception.expectMessage("abstract");
@@ -1335,7 +1330,7 @@ public void buildAbstractWithFlatten() {
         FakeDocument document = FakeDocument.of("test-string", null);
         FakeMappedItem item = FakeMappedItem.builder().aFakeDocument(document).build();
 
-        assertThat(tableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)),
+        assertThat(tableSchema.itemToMap(item, true),
                    is(singletonMap("documentString", AttributeValue.builder().s("test-string").build())));
     }
 
@@ -1356,7 +1351,7 @@ public void buildAbstractExtends() {
         FakeAbstractSubclass item = new FakeAbstractSubclass();
         item.setAString("test-string");
 
-        assertThat(subclassTableSchema.itemToMap(item, true, new DynamoDBEnhancedRequestConfiguration(SHALLOW)),
+        assertThat(subclassTableSchema.itemToMap(item, true),
                    is(singletonMap("aString", AttributeValue.builder().s("test-string").build())));
     }
 
@@ -1439,8 +1434,7 @@ public void usesCustomAttributeConverterProvider() {
                              .build();
 
         Map resultMap =
-            tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false,
-                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+                tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false);
         assertThat(resultMap.get("aString").s(), is(expectedString));
     }
 
@@ -1462,8 +1456,7 @@ public void usesCustomAttributeConverterProviders() {
                              .build();
 
         Map resultMap =
-            tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false,
-                                  new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+                tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(), false);
         assertThat(resultMap.get("aString").s(), is(expectedString));
     }
 
@@ -1499,7 +1492,7 @@ public void noConverterProvider_handlesCorrectly_whenAttributeConvertersAreSuppl
                         .build();
 
         Map resultMap = tableSchema.itemToMap(FakeMappedItem.builder().aString(originalString).build(),
-                                                                      false, new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+                false);
         assertThat(resultMap.get("aString").s(), is(expectedString));
     }
 
@@ -1520,7 +1513,7 @@ public void builder_canBuildForGenericClassType() {
         Map expectedMap =
             Collections.singletonMap("entity", AttributeValue.fromS("test-value"));
 
-        assertThat(envelopeTableSchema.itemToMap(testEnvelope, false, new DynamoDBEnhancedRequestConfiguration(SHALLOW)), equalTo(expectedMap));
+        assertThat(envelopeTableSchema.itemToMap(testEnvelope, false), equalTo(expectedMap));
         assertThat(envelopeTableSchema.mapToItem(expectedMap).getEntity(), equalTo("test-value"));
     }
 
@@ -1535,8 +1528,7 @@ private  void verifyAttribute(EnhancedType attributeType,
                                                                          .build();
         Map expectedMap = singletonMap("value", attributeValue);
 
-        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false,
-                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false);
         assertThat(resultMap, is(expectedMap));
 
         FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap);
@@ -1553,8 +1545,7 @@ private  void verifyNullAttribute(EnhancedType attributeType,
                                                                          .build();
         Map expectedMap = singletonMap("value", nullAttributeValue());
 
-        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false,
-                                                                      new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        Map resultMap = tableSchema.itemToMap(fakeMappedItem, false);
         assertThat(resultMap, is(expectedMap));
 
         FakeMappedItem resultItem = tableSchema.mapToItem(expectedMap);
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java
index 20ebe03c5ceb..d3ad194e64ae 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactGetItemsEnhancedRequestTest.java
@@ -19,7 +19,6 @@
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.nullValue;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
 
 import java.util.Arrays;
 import java.util.List;
@@ -32,7 +31,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient;
 import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
 import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
 import software.amazon.awssdk.services.dynamodb.model.Get;
@@ -96,8 +94,7 @@ public void builder_maximal_builder_style() {
 
     
     private List getTransactGetItems(FakeItem fakeItem) {
-        final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                            new DynamoDBEnhancedRequestConfiguration(NESTED));
+        final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true);
 
         TransactGetItem getItem = TransactGetItem.builder()
                                                       .get(Get.builder()
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java
index e34963c1abb0..c17becfe54bd 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/model/TransactWriteItemsEnhancedRequestTest.java
@@ -23,7 +23,6 @@
 import static org.junit.Assert.assertEquals;
 import static software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.util.Arrays;
 import java.util.List;
@@ -40,7 +39,6 @@
 import software.amazon.awssdk.enhanced.dynamodb.Expression;
 import software.amazon.awssdk.enhanced.dynamodb.Key;
 import software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem;
-import software.amazon.awssdk.enhanced.dynamodb.internal.DynamoDBEnhancedRequestConfiguration;
 import software.amazon.awssdk.enhanced.dynamodb.internal.client.ExtensionResolver;
 import software.amazon.awssdk.enhanced.dynamodb.internal.operations.TransactWriteItemsOperation;
 import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
@@ -187,8 +185,7 @@ public void builder_passRequestToken_shouldWork() {
     }
 
     private List getTransactWriteItems(FakeItem fakeItem) {
-        final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true,
-                                                                                            new DynamoDBEnhancedRequestConfiguration(SHALLOW));
+        final Map fakeItemMap = FakeItem.getTableSchema().itemToMap(fakeItem, true);
 
         TransactWriteItem putWriteItem = TransactWriteItem.builder()
                                                           .put(Put.builder()

From 4909472a2dfb0527be7c56b7539b3b1d0628a2b6 Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Thu, 11 Jul 2024 01:43:28 -0700
Subject: [PATCH 11/37] Added methods to AttributeMapping interface

---
 .../dynamodb/mapper/AttributeMapping.java     | 19 ++++++++-
 .../dynamodb/mapper/AttributeMappingTest.java | 40 +++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMappingTest.java

diff --git a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java
index 0c044090492b..69dcbde4d8ac 100644
--- a/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java
+++ b/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java
@@ -16,9 +16,26 @@
 package software.amazon.awssdk.enhanced.dynamodb.mapper;
 
 import software.amazon.awssdk.annotations.SdkPublicApi;
+import software.amazon.awssdk.utils.StringUtils;
 
 @SdkPublicApi
 public enum AttributeMapping {
     SHALLOW,
-    NESTED
+    NESTED;
+
+    public static AttributeMapping fromValue(String attributeMapping) {
+        if (attributeMapping == null) {
+            return null;
+        }
+        switch (StringUtils.capitalize(attributeMapping)) {
+            case "SHALLOW" : return SHALLOW;
+            case "NESTED" : return NESTED;
+            default:
+                return null;
+        }
+    }
+
+    public static String toString(AttributeMapping attributeMapping) {
+        return String.valueOf(attributeMapping);
+    }
 }
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMappingTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMappingTest.java
new file mode 100644
index 000000000000..4010deb4ad0b
--- /dev/null
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMappingTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ *  http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.enhanced.dynamodb.mapper;
+
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.NESTED;
+import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
+
+import org.junit.jupiter.api.Test;
+
+public class AttributeMappingTest {
+    private static String SHALLOW_MAPPING = "SHALLOW";
+    private static String NESTED_MAPPING = "NESTED";
+
+    @Test
+    public void whenPassedString_returnsAttributeMapping() {
+        assertEquals(SHALLOW, AttributeMapping.fromValue(SHALLOW_MAPPING));
+        assertEquals(NESTED, AttributeMapping.fromValue(NESTED_MAPPING));
+    }
+
+    @Test
+    public void whenPassedAttributeMapping_returnsString() {
+        assertEquals(SHALLOW_MAPPING, AttributeMapping.toString(SHALLOW));
+        assertEquals(NESTED_MAPPING, AttributeMapping.toString(NESTED));
+    }
+}

From c59988157a6fbd7dd07479764b92fda97194c9e9 Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Thu, 11 Jul 2024 01:50:37 -0700
Subject: [PATCH 12/37] Fixed unintentional indendation changes

---
 .../dynamodb/mapper/BeanTableSchemaTest.java  | 93 +++++++++----------
 .../mapper/StaticTableSchemaTest.java         | 22 ++---
 2 files changed, 55 insertions(+), 60 deletions(-)

diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java
index c1c61712243e..792a1821da91 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/BeanTableSchemaTest.java
@@ -27,8 +27,6 @@
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.nullAttributeValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.numberValue;
 import static software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue;
-import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.getMappingConfiguration;
-import static software.amazon.awssdk.enhanced.dynamodb.mapper.AttributeMapping.SHALLOW;
 
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
@@ -136,8 +134,7 @@ public void dynamoDbIgnore_propertyIsIgnored() {
         ignoredAttributeBean.setId("id-value");
         ignoredAttributeBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, getMappingConfiguration(false,
-                                                                                                                      SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false);
 
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -150,7 +147,7 @@ public void transient_propertyIsIgnored() {
         ignoredAttributeBean.setId("id-value");
         ignoredAttributeBean.setInteger2Attribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(ignoredAttributeBean, false);
 
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -166,8 +163,7 @@ public void setterAnnotations_alsoWork() {
 
         assertThat(beanTableSchema.tableMetadata().primaryPartitionKey(), is("id"));
 
-        Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, getMappingConfiguration(false,
-                                                                                                                     SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setterAnnotatedBean, false);
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
     }
@@ -189,8 +185,7 @@ public void dynamoDbFlatten_correctlyFlattensBeanAttributes() {
         flattenedBeanBean.setAttribute1("one");
         flattenedBeanBean.setAbstractBean(abstractBean);
 
-        Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, getMappingConfiguration(false,
-                                                                                                                   SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(flattenedBeanBean, false);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -205,7 +200,7 @@ public void dynamoDbPreserveEmptyObject_shouldInitializeAsEmptyClass() {
 
         bean.setInnerBean(innerPreserveEmptyBean);
 
-        Map itemMap = beanTableSchema.itemToMap(bean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(bean, true);
         NestedBean nestedBean = beanTableSchema.mapToItem(itemMap);
         assertThat(nestedBean.getInnerBean(), is(innerPreserveEmptyBean));
     }
@@ -218,7 +213,7 @@ public void dynamoDbIgnoreNulls_shouldOmitNulls() {
         bean.setInnerBean1(new AbstractBean());
         bean.setInnerBean2(new AbstractBean());
 
-        Map itemMap = beanTableSchema.itemToMap(bean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(bean, true);
         AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().m(new HashMap<>()).build();
 
         assertThat(itemMap.size(), is(2));
@@ -234,7 +229,7 @@ public void dynamoDbIgnoreNulls_onList_shouldOmitNulls() {
         bean.setInnerBeanList1(Collections.singletonList(new AbstractBean()));
         bean.setInnerBeanList2(Collections.singletonList(new AbstractBean()));
 
-        Map itemMap = beanTableSchema.itemToMap(bean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(bean, true);
         AttributeValue expectedMapForInnerBean1 = AttributeValue.builder().l(l -> l.m(emptyMap())).build();
         AttributeValue expectedMapForInnerBean2 = AttributeValue.builder()
                                                                 .l(l -> l.m(singletonMap("attribute2", nullAttributeValue())))
@@ -254,7 +249,7 @@ public void dynamoDbFlatten_correctlyFlattensImmutableAttributes() {
         flattenedImmutableBean.setAttribute1("one");
         flattenedImmutableBean.setAbstractImmutable(abstractImmutable);
 
-        Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(flattenedImmutableBean, false);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -275,7 +270,7 @@ public void documentBean_correctlyMapsBeanAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -302,7 +297,7 @@ public void documentBean_list_correctlyMapsBeanAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -336,7 +331,7 @@ public void documentBean_map_correctlyMapsBeanAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -356,7 +351,7 @@ public void documentBean_correctlyMapsImmutableAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -381,7 +376,7 @@ public void documentBean_list_correctlyMapsImmutableAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -413,7 +408,7 @@ public void documentBean_map_correctlyMapsImmutableAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -434,7 +429,7 @@ public void parameterizedDocumentBean_correctlyMapsAttributes() {
                                                         .m(singletonMap("attribute2", stringValue("two")))
                                                         .build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -461,7 +456,7 @@ public void parameterizedDocumentBean_list_correctlyMapsAttributes() {
                                                          .build();
         AttributeValue expectedList = AttributeValue.builder().l(expectedDocument1, expectedDocument2).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -495,7 +490,7 @@ public void parameterizedDocumentBean_map_correctlyMapsAttributes() {
         expectedAttributeValueMap.put("key2", expectedDocument2);
         AttributeValue expectedMap = AttributeValue.builder().m(expectedAttributeValueMap).build();
 
-        Map itemMap = beanTableSchema.itemToMap(documentBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(documentBean, true);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -510,7 +505,7 @@ public void extendedBean_correctlyExtendsAttributes() {
         extendedBean.setAttribute1("one");
         extendedBean.setAttribute2("two");
 
-        Map itemMap = beanTableSchema.itemToMap(extendedBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(extendedBean, false);
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
         assertThat(itemMap, hasEntry("attribute1", stringValue("one")));
@@ -528,7 +523,7 @@ public void itemToMap_nullAttribute_ignoreNullsTrue() {
         SimpleBean simpleBean = new SimpleBean();
         simpleBean.setId("id-value");
 
-        Map itemMap = beanTableSchema.itemToMap(simpleBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(simpleBean, true);
 
         assertThat(itemMap.size(), is(1));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -540,7 +535,7 @@ public void itemToMap_nullAttribute_ignoreNullsFalse() {
         SimpleBean simpleBean = new SimpleBean();
         simpleBean.setId("id-value");
 
-        Map itemMap = beanTableSchema.itemToMap(simpleBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(simpleBean, false);
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -554,7 +549,7 @@ public void itemToMap_nonNullAttribute() {
         simpleBean.setId("id-value");
         simpleBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(simpleBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(simpleBean, false);
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -607,7 +602,7 @@ public void enumBean_singleEnum() {
         enumBean.setId("id-value");
         enumBean.setTestEnum(EnumBean.TestEnum.ONE);
 
-        Map itemMap = beanTableSchema.itemToMap(enumBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(enumBean, true);
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -624,7 +619,7 @@ public void enumBean_listEnum() {
         enumBean.setId("id-value");
         enumBean.setTestEnumList(Arrays.asList(EnumBean.TestEnum.ONE, EnumBean.TestEnum.TWO));
 
-        Map itemMap = beanTableSchema.itemToMap(enumBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(enumBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .l(stringValue("ONE"),
@@ -645,7 +640,7 @@ public void listBean_stringList() {
         listBean.setId("id-value");
         listBean.setStringList(Arrays.asList("one", "two", "three"));
 
-        Map itemMap = beanTableSchema.itemToMap(listBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(listBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .l(stringValue("one"),
@@ -668,7 +663,7 @@ public void listBean_stringListList() {
         listBean.setId("id-value");
         listBean.setStringListList(Arrays.asList(Arrays.asList("one", "two"), Arrays.asList("three", "four")));
 
-        Map itemMap = beanTableSchema.itemToMap(listBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(listBean, true);
 
         AttributeValue list1 = AttributeValue.builder().l(stringValue("one"), stringValue("two")).build();
         AttributeValue list2 = AttributeValue.builder().l(stringValue("three"), stringValue("four")).build();
@@ -695,7 +690,7 @@ public void setBean_stringSet() {
         stringSet.add("three");
         setBean.setStringSet(stringSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ss("one", "two", "three")
@@ -720,7 +715,7 @@ public void setBean_integerSet() {
         integerSet.add(3);
         setBean.setIntegerSet(integerSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -745,7 +740,7 @@ public void setBean_longSet() {
         longSet.add(3L);
         setBean.setLongSet(longSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -770,7 +765,7 @@ public void setBean_shortSet() {
         shortSet.add((short)3);
         setBean.setShortSet(shortSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -795,7 +790,7 @@ public void setBean_byteSet() {
         byteSet.add((byte)3);
         setBean.setByteSet(byteSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1", "2", "3")
@@ -820,7 +815,7 @@ public void setBean_doubleSet() {
         doubleSet.add(3.3);
         setBean.setDoubleSet(doubleSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1.1", "2.2", "3.3")
@@ -845,7 +840,7 @@ public void setBean_floatSet() {
         floatSet.add(3.3f);
         setBean.setFloatSet(floatSet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .ns("1.1", "2.2", "3.3")
@@ -874,7 +869,7 @@ public void setBean_binarySet() {
         binarySet.add(buffer3);
         setBean.setBinarySet(binarySet);
 
-        Map itemMap = beanTableSchema.itemToMap(setBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(setBean, true);
 
         AttributeValue expectedAttributeValue = AttributeValue.builder()
                                                               .bs(buffer1, buffer2, buffer3)
@@ -900,7 +895,7 @@ public void mapBean_stringStringMap() {
 
         mapBean.setStringMap(testMap);
 
-        Map itemMap = beanTableSchema.itemToMap(mapBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(mapBean, true);
 
         Map expectedMap = new HashMap<>();
         expectedMap.put("one", stringValue("two"));
@@ -929,7 +924,7 @@ public void mapBean_mapWithNullValue() {
 
         mapBean.setStringMap(testMap);
 
-        Map itemMap = beanTableSchema.itemToMap(mapBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(mapBean, true);
 
         Map expectedMap = new HashMap<>();
         expectedMap.put("one", AttributeValues.nullAttributeValue());
@@ -958,7 +953,7 @@ public void mapBean_nestedStringMap() {
 
         mapBean.setNestedStringMap(testMap);
 
-        Map itemMap = beanTableSchema.itemToMap(mapBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(mapBean, true);
 
         Map expectedMap = new HashMap<>();
         expectedMap.put("five", AttributeValue.builder().m(singletonMap("one", stringValue("two"))).build());
@@ -992,7 +987,7 @@ public void commonTypesBean() {
         commonTypesBean.setFloatAttribute((float) 67.8);
         commonTypesBean.setBinaryAttribute(binaryLiteral);
 
-        Map itemMap = beanTableSchema.itemToMap(commonTypesBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(commonTypesBean, true);
 
         assertThat(itemMap.size(), is(9));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -1023,7 +1018,7 @@ public void primitiveTypesBean() {
         primitiveTypesBean.setDoubleAttribute(56.7);
         primitiveTypesBean.setFloatAttribute((float) 67.8);
 
-        Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, getMappingConfiguration(true, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(primitiveTypesBean, true);
 
         assertThat(itemMap.size(), is(8));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -1083,7 +1078,7 @@ public void usesCustomAttributeConverter() {
         converterBean.setIntegerAttribute(123);
         converterBean.setAttributeItem(attributeItem);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, false);
 
         assertThat(itemMap.size(), is(3));
         assertThat(itemMap, hasEntry("id", stringValue("id-value")));
@@ -1109,7 +1104,7 @@ public void usesCustomAttributeConverterProvider() {
         converterBean.setId("id-value");
         converterBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, false);
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value-custom")));
@@ -1123,13 +1118,13 @@ public void usesCustomAttributeConverterProvider() {
     @Test
     public void usesCustomAttributeConverterProviders() {
         BeanTableSchema beanTableSchema =
-            BeanTableSchema.create(MultipleConverterProvidersBean.class);
+                BeanTableSchema.create(MultipleConverterProvidersBean.class);
 
         MultipleConverterProvidersBean converterBean = new MultipleConverterProvidersBean();
         converterBean.setId("id-value");
         converterBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, false);
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value-custom")));
@@ -1149,13 +1144,13 @@ public void emptyConverterProviderList_fails_whenAttributeConvertersAreMissing()
     @Test
     public void emptyConverterProviderList_correct_whenAttributeConvertersAreSupplied() {
         BeanTableSchema beanTableSchema =
-            BeanTableSchema.create(EmptyConverterProvidersValidBean.class);
+                BeanTableSchema.create(EmptyConverterProvidersValidBean.class);
 
         EmptyConverterProvidersValidBean converterBean = new EmptyConverterProvidersValidBean();
         converterBean.setId("id-value");
         converterBean.setIntegerAttribute(123);
 
-        Map itemMap = beanTableSchema.itemToMap(converterBean, getMappingConfiguration(false, SHALLOW));
+        Map itemMap = beanTableSchema.itemToMap(converterBean, false);
 
         assertThat(itemMap.size(), is(2));
         assertThat(itemMap, hasEntry("id", stringValue("id-value-custom")));
diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java
index 2989edb6c7be..368ef26b9648 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticTableSchemaTest.java
@@ -747,7 +747,7 @@ void setAString(String aString) {
             this.aString = aString;
         }
     }
-
+    
     private static final Collection> ATTRIBUTES = Arrays.asList(
         StaticAttribute.builder(FakeMappedItem.class, Boolean.class)
                        .name("a_primitive_boolean")
@@ -900,7 +900,7 @@ public void mapperCanHandleDocument() {
         Map expectedMap = new HashMap<>();
         expectedMap.put("documentInteger", AttributeValue.builder().n("123").build());
         expectedMap.put("documentString", AttributeValue.builder().s("test-123").build());
-
+        
         verifyNullableAttribute(EnhancedType.documentOf(FakeDocument.class, FAKE_DOCUMENT_TABLE_SCHEMA),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAFakeDocument)
@@ -1122,7 +1122,7 @@ public void mapperCanHandleNestedLists() {
     public void mapperCanHandleIntegerSet() {
         Set valueSet = new HashSet<>(asList(1, 2, 3));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Integer.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAnIntegerSet)
@@ -1135,7 +1135,7 @@ public void mapperCanHandleIntegerSet() {
     public void mapperCanHandleStringSet() {
         Set valueSet = new HashSet<>(asList("one", "two", "three"));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(String.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAStringSet)
@@ -1148,7 +1148,7 @@ public void mapperCanHandleStringSet() {
     public void mapperCanHandleLongSet() {
         Set valueSet = new HashSet<>(asList(1L, 2L, 3L));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Long.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getALongSet)
@@ -1161,7 +1161,7 @@ public void mapperCanHandleLongSet() {
     public void mapperCanHandleShortSet() {
         Set valueSet = new HashSet<>(asList((short) 1, (short) 2, (short) 3));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Short.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAShortSet)
@@ -1174,7 +1174,7 @@ public void mapperCanHandleShortSet() {
     public void mapperCanHandleByteSet() {
         Set valueSet = new HashSet<>(asList((byte) 1, (byte) 2, (byte) 3));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Byte.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAByteSet)
@@ -1187,7 +1187,7 @@ public void mapperCanHandleByteSet() {
     public void mapperCanHandleDoubleSet() {
         Set valueSet = new HashSet<>(asList(1.2, 3.4, 5.6));
         List expectedList = valueSet.stream().map(Object::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Double.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getADoubleSet)
@@ -1200,7 +1200,7 @@ public void mapperCanHandleDoubleSet() {
     public void mapperCanHandleFloatSet() {
         Set valueSet = new HashSet<>(asList(1.2f, 3.4f, 5.6f));
         List expectedList = valueSet.stream().map(Object::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Float.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAFloatSet)
@@ -1218,7 +1218,7 @@ public void mapperCanHandleGenericMap() {
         Map attributeValueMap = new HashMap<>();
         attributeValueMap.put("one", AttributeValue.builder().s("two").build());
         attributeValueMap.put("three", AttributeValue.builder().s("four").build());
-
+        
         verifyNullableAttribute(EnhancedType.mapOf(String.class, String.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAStringMap)
@@ -1254,7 +1254,7 @@ public void mapperCanHandleIntDoubleMap() {
         Map attributeValueMap = new HashMap<>();
         attributeValueMap.put("1", AttributeValue.builder().n("1.0").build());
         attributeValueMap.put("2", AttributeValue.builder().n("3.0").build());
-
+        
         verifyNullableAttribute(EnhancedType.mapOf(Integer.class, Double.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAIntDoubleMap)

From 8a222ce8e363267bda41266c119cc1dea78fd625 Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Thu, 11 Jul 2024 01:52:35 -0700
Subject: [PATCH 13/37] Fixed unintentional indendation changes

---
 .../StaticImmutableTableSchemaTest.java       | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java
index da75f3b2bdc5..5c1b8b2a4d11 100644
--- a/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java
+++ b/services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/StaticImmutableTableSchemaTest.java
@@ -749,7 +749,7 @@ void setAString(String aString) {
             this.aString = aString;
         }
     }
-
+    
     private static final Collection> ATTRIBUTES = Arrays.asList(
         StaticAttribute.builder(FakeMappedItem.class, Boolean.class)
                        .name("a_primitive_boolean")
@@ -903,7 +903,7 @@ public void mapperCanHandleDocument() {
         Map expectedMap = new HashMap<>();
         expectedMap.put("documentInteger", AttributeValue.builder().n("123").build());
         expectedMap.put("documentString", AttributeValue.builder().s("test-123").build());
-
+        
         verifyNullableAttribute(EnhancedType.documentOf(FakeDocument.class, FAKE_DOCUMENT_TABLE_SCHEMA),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAFakeDocument)
@@ -1125,7 +1125,7 @@ public void mapperCanHandleNestedLists() {
     public void mapperCanHandleIntegerSet() {
         Set valueSet = new HashSet<>(asList(1, 2, 3));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Integer.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAnIntegerSet)
@@ -1138,7 +1138,7 @@ public void mapperCanHandleIntegerSet() {
     public void mapperCanHandleStringSet() {
         Set valueSet = new HashSet<>(asList("one", "two", "three"));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(String.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAStringSet)
@@ -1151,7 +1151,7 @@ public void mapperCanHandleStringSet() {
     public void mapperCanHandleLongSet() {
         Set valueSet = new HashSet<>(asList(1L, 2L, 3L));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Long.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getALongSet)
@@ -1164,7 +1164,7 @@ public void mapperCanHandleLongSet() {
     public void mapperCanHandleShortSet() {
         Set valueSet = new HashSet<>(asList((short) 1, (short) 2, (short) 3));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Short.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAShortSet)
@@ -1177,7 +1177,7 @@ public void mapperCanHandleShortSet() {
     public void mapperCanHandleByteSet() {
         Set valueSet = new HashSet<>(asList((byte) 1, (byte) 2, (byte) 3));
         List expectedList = valueSet.stream().map(Objects::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Byte.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAByteSet)
@@ -1190,7 +1190,7 @@ public void mapperCanHandleByteSet() {
     public void mapperCanHandleDoubleSet() {
         Set valueSet = new HashSet<>(asList(1.2, 3.4, 5.6));
         List expectedList = valueSet.stream().map(Object::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Double.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getADoubleSet)
@@ -1203,7 +1203,7 @@ public void mapperCanHandleDoubleSet() {
     public void mapperCanHandleFloatSet() {
         Set valueSet = new HashSet<>(asList(1.2f, 3.4f, 5.6f));
         List expectedList = valueSet.stream().map(Object::toString).collect(toList());
-
+        
         verifyNullableAttribute(EnhancedType.setOf(Float.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAFloatSet)
@@ -1221,7 +1221,7 @@ public void mapperCanHandleGenericMap() {
         Map attributeValueMap = new HashMap<>();
         attributeValueMap.put("one", AttributeValue.builder().s("two").build());
         attributeValueMap.put("three", AttributeValue.builder().s("four").build());
-
+        
         verifyNullableAttribute(EnhancedType.mapOf(String.class, String.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAStringMap)
@@ -1239,7 +1239,7 @@ public void mapperCanHandleIntDoubleMap() {
         Map attributeValueMap = new HashMap<>();
         attributeValueMap.put("1", AttributeValue.builder().n("1.0").build());
         attributeValueMap.put("2", AttributeValue.builder().n("3.0").build());
-
+        
         verifyNullableAttribute(EnhancedType.mapOf(Integer.class, Double.class),
                                 a -> a.name("value")
                                       .getter(FakeMappedItem::getAIntDoubleMap)

From 7cedb09441a26abf83598bf14c4b1f6b3abf783a Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Thu, 11 Jul 2024 10:05:42 -0700
Subject: [PATCH 14/37] Add changelogs

---
 .changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 .changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json

diff --git a/.changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json b/.changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json
new file mode 100644
index 000000000000..156d99ac7161
--- /dev/null
+++ b/.changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json
@@ -0,0 +1,6 @@
+{
+    "type": "bugfix",
+    "category": "AWS SDK for Java v2",
+    "contributor": "anirudh9391",
+    "description": "Modify Enhanced Client to work on successfully updating nested attributes without loss of information"
+}

From 459d0405ba3772908a4a32ea00b9bce73d154f09 Mon Sep 17 00:00:00 2001
From: Krishnan 
Date: Wed, 24 Jul 2024 00:52:03 -0700
Subject: [PATCH 15/37] Introduce a new method to transform input to be able to
 perform update operations on nested DynamoDB object attributes.

---
 .../bugfix-AWSSDKforJavav2-2a80679.json       |   2 +-
 .idea/codeStyles/Project.xml                  |   1 +
 .../internal/ChannelPipelineInitializer.java  |   2 +
 .../awssdk/enhanced/dynamodb/TableSchema.java |  21 +--
 .../document/DocumentTableSchema.java         |  11 +-
 .../internal/EnhancedClientUtils.java         |  11 +-
 .../attribute/DocumentAttributeConverter.java |   9 +-
 .../internal/mapper/MetaTableSchema.java      |  11 +-
 .../internal/operations/PutItemOperation.java |   6 +-
 .../operations/UpdateItemOperation.java       |  70 +++++++++-
 .../update/UpdateExpressionUtils.java         |   2 +-
 .../dynamodb/mapper/AttributeMapping.java     |  41 ------
 .../dynamodb/mapper/MappingConfiguration.java | 124 ------------------
 .../mapper/StaticImmutableTableSchema.java    |  49 +------
 .../dynamodb/mapper/WrappedTableSchema.java   |  10 +-
 .../annotations/DynamoDbIgnoreNulls.java      |  10 +-
 .../functionaltests/UpdateBehaviorTest.java   | 100 ++++++++------
 .../models/CompositeRecord.java               |  12 +-
 .../internal/DefaultDocumentTest.java         |  12 +-
 .../immutable/MetaTableSchemaTest.java        |  20 +--
 .../operations/DeleteItemOperationTest.java   |  18 +--
 .../operations/GetItemOperationTest.java      |  10 +-
 .../operations/PutItemOperationTest.java      |  21 +--
 .../TransactWriteItemsOperationTest.java      |  11 +-
 .../operations/UpdateItemOperationTest.java   |  58 ++------
 .../UpdateItemOperationTransactTest.java      |  12 +-
 .../dynamodb/mapper/AttributeMappingTest.java |  40 ------
 .../mapper/MappingConfigurationTest.java      |  55 --------
 28 files changed, 188 insertions(+), 561 deletions(-)
 delete mode 100644 services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMapping.java
 delete mode 100644 services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfiguration.java
 delete mode 100644 services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/AttributeMappingTest.java
 delete mode 100644 services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mapper/MappingConfigurationTest.java

diff --git a/.changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json b/.changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json
index 156d99ac7161..f8c315dfb1ff 100644
--- a/.changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json
+++ b/.changes/next-release/bugfix-AWSSDKforJavav2-2a80679.json
@@ -2,5 +2,5 @@
     "type": "bugfix",
     "category": "AWS SDK for Java v2",
     "contributor": "anirudh9391",
-    "description": "Modify Enhanced Client to work on successfully updating nested attributes without loss of information"
+    "description": "Introduce a new method to transform input to be able to perform update operations on nested DynamoDB object attributes."
 }
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 82511b2671f7..a7d7cfec5bea 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -44,6 +44,7 @@