Skip to content

DynamoDbIgnoreNulls example assertions are incorrect #4459

@tkhill-AWS

Description

@tkhill-AWS

Describe the issue

The javadoc for DynamoDbIgnoreNulls shows two assertions at the end.

 // innerBean1 w/ @DynamoDbIgnoreNulls does not have any attribute values because all the fields are null
 assertThat(itemMap.get("innerBean1").m(), empty());

 // innerBean2 w/o @DynamoDbIgnoreNulls has a NULLL attribute.
 assertThat(nestedBean.getInnerBean2(), hasEntry("attribute", nullAttributeValue()));

Assuming that hamcrest matchers are being used, for example

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;

I found that assertThat(itemMap.get("innerBean1").m(), empty()); does not compile. Matchers.empty() is used to check a Collection, but itemMap.get("innerBean1").m() returns a Map. A Map is not a Collection.

Also, the second assertion:

assertThat(nestedBean.getInnerBean2(), hasEntry("attribute", nullAttributeValue()));

doesn't make since since nestedBean.getInnerBean2(), returns null and hasEntry("attribute", nullAttributeValue()) is checking for an entry in a map.

Links

https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/enhanced/dynamodb/mapper/annotations/DynamoDbIgnoreNulls.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationThis is a problem with documentation.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions