Increase code coverage on dynamodb-enhanced module#6700
Increase code coverage on dynamodb-enhanced module#6700andreas-grafenberger wants to merge 1 commit intoaws:masterfrom
Conversation
a024740 to
fcfbd00
Compare
337c117 to
f97adfc
Compare
1764264 to
8dd1add
Compare
| @Test | ||
| public void returnsCorrectOperationName() { | ||
| DeleteTableOperation<FakeItemWithIndices> operation = DeleteTableOperation.create(); | ||
| assertThat(operation.operationName().label(), is("DeleteItem")); |
There was a problem hiding this comment.
is("DeleteItem") , should this be delete table ?
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| StaticCounterRecord that = (StaticCounterRecord) o; |
There was a problem hiding this comment.
Should this be ?
BeanCounterRecord that = (BeanCounterRecord) o;
|
|
||
| AutoGeneratedTimestampRecordExtension.Builder rebuilt = extension.toBuilder(); | ||
|
|
||
| assertThat(rebuilt).isNotNull(); |
There was a problem hiding this comment.
we only check is it is not null but shouldn't we check if we preserved the value ?\
assertThat(generatedInstant).isEqualTo(Instant.parse("2025-01-01T00:00:00Z"));|
|
||
| @TestFactory | ||
| Stream<DynamicTest> testDefaultMethodsThrowUnsupportedOperation() { | ||
| return scanPackageForClasses(BASE_PACKAGE) |
There was a problem hiding this comment.
This will silently return nothing and the test will be passed automatically. You may consider to check if we have any tests returned from the operation before returning values..
Stream<DynamicTest> testDefaultMethodsThrowUnsupportedOperation() {
List<DynamicTest> tests = scanPackageForClasses(BASE_PACKAGE)
.filter(Class::isInterface)
.filter(this::hasDefaultMethods)
.collect(toList())
.stream()
.flatMap(this::createTestsForInterface)
.collect(toList());
assertThat(tests).as("Expected to find interfaces with default UnsupportedOperation methods, "
+ "but classpath scan returned nothing. Check classpath configuration.")
.isNotEmpty();
return tests.stream();| mappedTable.putItem(record); | ||
| RecordWithAutogeneratedUuid result = mappedTable.scan().items().stream().findFirst() | ||
| .orElseThrow(() -> new AssertionError("No record found")); | ||
| isValidUuid(result.getId()); |
There was a problem hiding this comment.
This is not an assertion but I think we will be fixed in PR 6373 and we can rebaseline on that
| return sort; | ||
| } | ||
|
|
||
| public String stringAttribute() { |
There was a problem hiding this comment.
should this be getStringAttribute() ?
I think the SDK's ImmutableTableSchema uses getter naming conventions. This may cause the attribute to not be mapped correctly
| return sort; | ||
| } | ||
|
|
||
| public String stringAttribute() { |
There was a problem hiding this comment.
same as in abstract model, shouldn't this be getStringAttribute ?
| } | ||
|
|
||
| @Test | ||
| public void createKeyFromItem_withPartitionKeyOnly_createsCorrectKey() { |
There was a problem hiding this comment.
is this really different than createKeyFromItem_partitionKeyOnly_returnsKeyWithPartitionOnly ?
| } | ||
|
|
||
| @Test | ||
| public void keyRef_withSpecialCharacters_cleansAndFormatsKey() { |
There was a problem hiding this comment.
is this testing something different than keyRef_attributeNameWithSpecialCharacters_returnsCleanedReference ?
| import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean; | ||
| import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey; | ||
|
|
||
| public class ChainExtensionTest extends LocalDynamoDbSyncTestBase { |
There was a problem hiding this comment.
I think more important part of chaining extensions is interaction across operations. Missing: updateItem (does version increment while UUID stays stable?)
Could you add tests for updateItem, batchWriteItem, and transactWriteItems?
The updateItem case will be worth to test, AutoGeneratedUuidExtension always regenerates the UUID on every write, while VersionedRecordExtension increments the version. What happens when both run on an update? Does the version increment correctly? Does the timestamp update?
Motivation and Context
The goal of this work is to increase unit, functional, and integration code coverage for the
aws-sdk-java-v2/services-custom/dynamodb-enhancedmodule.Initial coverage:
Target coverage:
Achieved coverage:
These results exceed the defined targets and significantly improve confidence in the correctness and stability of the enhanced DynamoDB module.
Modifications
This pull request expands code coverage across the DynamoDB Enhanced Client by introducing new unit, functional, and integration tests targeting previously uncovered or partially covered code paths.
Testing
Screenshots
Initial coverage:
Achieved coverage:
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License