Skip to content

containsExactly does not work properly with maps not using equals to compare keys #2165

@joel-costigliola

Description

@joel-costigliola

Summary

This test should pass but fails.

  @Test
  void should_pass_if_case_insensitive_actual_contains_given_entries_in_rder() {
    // GIVEN
    actual = new CaseInsensitiveMap<>();
    actual.put( "Color", "green" );
    actual.put( "NAME", "Yoda" );

    // THEN
    maps.assertContainsExactly(someInfo(), actual, entry("COLOR", "green"), entry("Name", "Yoda"));
  }

The underlying issue is when containsExactly verifies that the entries are in the same order, it ends up comparing "Color" against "COLOR" with equals instead of the actual map key comparison strategy (case insensitive string in the example).

It's not yet clear if there is a way to address this issue, if not we would have to mention the limitation in the javadoc.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions