Skip to content

RecursiveComparisonConfiguration is not taken into account for map keys #3835

Description

@jean-tissot

Hello,
When comparing two maps, the recursive comparison doesn't seem to be taken into account for keys.

  • assertj core version: 4.0.0-M1 (and earlier)
  • java version: 21

I added two test cases in RecursiveComparisonAssert_for_maps_Test to reproduce the issue (should_pass_when_keys_are_equal and should_honor_ignored_fields_in_keys). Here is the first one :

  @Test
  void should_pass_when_keys_are_equal() {
    // GIVEN
    Person sheldon = new Person("Sheldon");
    Person leonard = new Person("Leonard");
    Person raj = new Person("Rajesh");

    PersonDto sheldonDto = new PersonDto("Sheldon");
    PersonDto leonardDto = new PersonDto("Leonard");
    PersonDto rajDto = new PersonDto("Rajesh");

    Map<Person, String> actual = mapOf(entry(sheldon, sheldon.name),
                                       entry(leonard, leonard.name),
                                       entry(raj, raj.name));
    Map<PersonDto, String> expected = mapOf(entry(sheldonDto, sheldonDto.name),
                                            entry(leonardDto, leonardDto.name),
                                            entry(rajDto, rajDto.name));
    // WHEN/THEN
    then(actual).usingRecursiveComparison(recursiveComparisonConfiguration)
                .isEqualTo(expected);
 }

Could this issue be linked to #2165 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions