java.lang.Object
io.helidon.common.testing.junit5.MapMatcher

public final class MapMatcher extends Object
Hamcrest matchers for Map.
  • Method Details

    • mapEqualTo

      public static <K, V> org.hamcrest.Matcher<Map<K,V>> mapEqualTo(Map<K,V> expected)
      A matcher that performs Map deep equality.

      Usage example:

           assertThat(actualMap, mapEqualTo(expectedMap));
       
      This method targets trees implemented using Map where values of type Map are considered tree nodes, and values of any other type are considered leaf nodes.

      The deep-equality is performed by diffing a flat string representation of each map. If the diff yields no differences, the maps are considered deeply equal.

      The entries are compared using strings, both keys and leaf nodes must implement Object.toString().

      Type Parameters:
      K - type of the map keys
      V - type of the map values
      Parameters:
      expected - expected map
      Returns:
      matcher validating the Map is deeply equal