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

Support ignoring collection order in Recursive comparison API #1494

Closed
zeljko-mirovic opened this issue Apr 30, 2019 · 4 comments · Fixed by #1495
Closed

Support ignoring collection order in Recursive comparison API #1494

zeljko-mirovic opened this issue Apr 30, 2019 · 4 comments · Fixed by #1495
Milestone

Comments

@zeljko-mirovic
Copy link
Contributor

It will be nice to be able to ignore collection order with Recursive comparison API.
Instead of writing something like:

assertThat(actual).usingRecursiveComparison()
                  .ignoringFields("unorderedCollection")
                  .isEqualTo(expected);
assertThat(actual.getUnorderedCollection()).hasSameElementsAs(expected.getUnorderedCollection());

to have option to ignore collection order like this:

assertThat(actual).usingRecursiveComparison()
                  .ignoringCollectionOrderInFields("unorderedCollection")
                  .isEqualTo(expected);
@joel-costigliola
Copy link
Member

Sure, I had a bullet point in #1002 for it.

@joel-costigliola joel-costigliola added this to the 3.13 milestone Apr 30, 2019
@joel-costigliola
Copy link
Member

@zeljko-mirovic do you have a use case where specifying fields is necessary ?
I was at first considering a global option ignoringCollectionOrder() for all collections.

@zeljko-mirovic
Copy link
Contributor Author

Yes I do.
I am asserting complex DTO generated by maven plugin. All collections in DTO are Lists but some of them are backed up by entities using Lists and some by entities using Sets.

@joel-costigliola
Copy link
Member

alright fair enough.

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

Successfully merging a pull request may close this issue.

2 participants