https://github.com/assertj/assertj-core/blob/f27b022a369ba731ed72413f6c10c82a9e539495/src/main/java/org/assertj/core/internal/Maps.java#L745
The call mentioned in the link fails with IllegalArgumentException if entries is empty, and actual is not. This, however, would work if actual is empty as well (the mentioned line is not executed in this case). Thus, execution success depends on actual input, which is the most frequently changing part of the test.
I would expect this code to fail with AssertionError with proper message (actual should be empty, but was XXX)
I agree the error message should be as you said.
Are you keen to contribute it?
@joel-costigliola I would like to pick it up. If it's free for me to take, please assign it to me.
Thanks @abhijeetshuklaoist
@abhijeetshuklaoist have you made any progress?
Sorry I have been occupied for some time. I will get to it right away.
Thanks!
@joel-costigliola What should be the correct behaviour here?
Below are the use cases that I think should be there, if let me know if my understanding is correct.
that's correct, 1. and 2. are already handled properly, 3. can be improved with a better error message.
We must not change failIfEmpty because it is used elsewhere, instead we replace it in assertContainsOnly and assertContainsExactly by calling assertEmpty as you suggested (good idea!) if entries is empty.
Does that make sense?