Skip to content
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

MapAssert check contains key when extracting keys implicitly #3292

Open
xenoterracide opened this issue Dec 8, 2023 · 0 comments
Open

MapAssert check contains key when extracting keys implicitly #3292

xenoterracide opened this issue Dec 8, 2023 · 0 comments

Comments

@xenoterracide
Copy link

xenoterracide commented Dec 8, 2023

Feature summary

MapAssert.extractingByKeys (and related) should verify the key exists to avoid an NPE

Example

This works

Assertions.assertThat(altIds).hasSize(1).containsKey(alternateId).extractingByKeys(alternateId) //check more stuff

This can result in an NPE if the key is missing, but I believe should be implicitly equivalent to the above giving a better error if extraction can not occur. If notEmpty() is not called, it probably also should be.

Assertions.assertThat(altIds).hasSize(1).extractingByKeys(alternateId) // check more stuff

if the NPE is a bug this is version 3.23.0

@xenoterracide xenoterracide changed the title MapAssert MapAssert check contains key when extracting keys implicitly Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant