-1

I am using hamcrest and junit to perform the tests, I need to compare 2 maps that have the same items but in different order, so assertEquals does not work for me. I have already seen the answers that have been put to that, but I have not been able to import the required methods.

I am importing in the following way

import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import static org.junit.Assert.assertThat;

and then I try the next thing I've seen in the answers

assertThat(expectedMap, containsInAnyOrder(receivedMap));

but does not recognize the method assertThat, the IDE shows me a warning that asks me to create the method

IntelliJ error tooltip: "assertThat(java.util.Map,org.hamcrest.Matcher>>)"

Thiru
  • 2,541
  • 4
  • 25
  • 39
kmilo93sd
  • 791
  • 1
  • 15
  • 35

2 Answers2

1

Map does not implement Iterable. Thus, the method signature does not match with the inferred argument types Map<?> and Matcher<Iterable<?>>.

Marc Philipp
  • 1,848
  • 12
  • 25
0

You are importing the wrong assertThat method, what you want is the one from hamcrest :

import static org.hamcrest.MatcherAssert.assertThat;
Arnaud
  • 17,229
  • 3
  • 31
  • 44