Skip to content

Assert on AttributeValue List type to ensure consistency when empty and non-empty #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public void testToAttributeValueV1_L() {
com.amazonaws.services.dynamodbv2.model.AttributeValue convertedAttributeValueL =
DynamodbAttributeValueTransformer.toAttributeValueV1(attributeValueL_event);
Assertions.assertEquals(attributeValueL_v1, convertedAttributeValueL);
Assertions.assertEquals("ArrayList", convertedAttributeValueL.getL().getClass().getSimpleName(), "List is mutable");
}

@Test
Expand Down Expand Up @@ -262,12 +263,14 @@ public void testToAttributeValueV1_DoesNotThrowWhenEmpty_BS() {

@Test
public void testToAttributeValueV1_DoesNotThrowWhenEmpty_L() {
Assertions.assertDoesNotThrow(() ->
DynamodbAttributeValueTransformer.toAttributeValueV1(new AttributeValue().withL())
);
Assertions.assertDoesNotThrow(() ->
DynamodbAttributeValueTransformer.toAttributeValueV1(new AttributeValue().withL(Collections.emptyList()))
);
Assertions.assertDoesNotThrow(() -> {
com.amazonaws.services.dynamodbv2.model.AttributeValue attributeValue = DynamodbAttributeValueTransformer.toAttributeValueV1(new AttributeValue().withL());
Assertions.assertEquals("ArrayList", attributeValue.getL().getClass().getSimpleName(), "List is mutable");
});
Assertions.assertDoesNotThrow(() -> {
com.amazonaws.services.dynamodbv2.model.AttributeValue attributeValue = DynamodbAttributeValueTransformer.toAttributeValueV1(new AttributeValue().withL(Collections.emptyList()));
Assertions.assertEquals("ArrayList", attributeValue.getL().getClass().getSimpleName(), "List is mutable");
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void testToAttributeValueV2_L() {
software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueL =
DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueL_event);
Assertions.assertEquals(attributeValueL_v2, convertedAttributeValueL);
Assertions.assertEquals("UnmodifiableRandomAccessList", convertedAttributeValueL.l().getClass().getSimpleName(), "List is immutable");
}

@Test
Expand Down Expand Up @@ -266,12 +267,14 @@ public void testToAttributeValueV2_DoesNotThrowWhenEmpty_BS() {

@Test
public void testToAttributeValueV2_DoesNotThrowWhenEmpty_L() {
Assertions.assertDoesNotThrow(() ->
DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL())
);
Assertions.assertDoesNotThrow(() ->
DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL(Collections.emptyList()))
);
Assertions.assertDoesNotThrow(() -> {
software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValue = DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL());
Assertions.assertEquals("UnmodifiableRandomAccessList", attributeValue.l().getClass().getSimpleName(), "List is immutable");
});
Assertions.assertDoesNotThrow(() -> {
software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValue = DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL(Collections.emptyList()));
Assertions.assertEquals("UnmodifiableRandomAccessList", attributeValue.l().getClass().getSimpleName(), "List is immutable");
});
}

@Test
Expand Down