I am Mapdeclared as follows:
Map<String, Object> data
I put in it Stringand checked its meaning as follows:
assertEquals("value", data.get("key"));
Now I would like to rewrite the check to use assertThatinstead assertEquals. I tried the following:
assertThat(data.get("key"), equalTo("value"));
And of course, this did not work due to type mismatch:
Wrong 2nd argument type. Found: 'org.hamcrest.Matcher<java.lang.String>', required: 'org.hamcrest.Matcher<? super java.lang.Object>' less...
The explicit type of casting the first argument to Stringhelps, but I would like to avoid it. For example, it assertEqualsdoes not require typing. So, how can I verify that the value that was placed in the object Mapdeclared above is equal to the concrete Stringusing the method assertThat?