title: How to use Hamcrest to inspect Map items
body: <p>I have been recently using Hamcrest library to write some tests and quite successful but now I need to do something more complex and started to see a lot of difficulties. I need to inpsect and verify the properties of the items in a Map. My production code looks something like this:</p>
  
  <pre><code>    Map&lt;String, List&lt;MyItem&gt;&gt; map = new HashMap&lt;String, List&lt;MyItem&gt;&gt;();
      map.put("one", Arrays.asList(new MyItem("One")));
      map.put("two",  Arrays.asList(new MyItem("Two")));
      map.put("three",  Arrays.asList(new MyItem("Three")));
  </code></pre>
  
  <p>I want to write some test codes like the following, but it doesn't compile. Looks like Hamcrest's hasEntry is type-parametered, while hasItem and hasProperty only expect Object.</p>
  
  <pre><code>    assertThat(map, Matchers.&lt;String, List&lt;MyItem&gt;&gt;hasEntry("one",  hasItem(hasProperty("name", is("One")))));
  </code></pre>
  
  <p>My IDE (Eclipse) is giving this error message: The parameterized method <code>&lt;String, List&lt;HamcrestTest.MyItem&gt;&gt;hasEntry(String, List&lt;HamcrestTest.MyItem&gt;)</code> of type <code>Matchers</code> is not applicable for the arguments <code>(String, Matcher&lt;Iterable&lt;? super Object&gt;&gt;)</code>. For one thing I think Eclipse is confused of which <code>hasEntry</code> method I wanted to use, it should be <code>hasEntry(org.hamcrest.Matcher&lt;? super K&gt; keyMatcher, org.hamcrest.Matcher&lt;? super V&gt; valueMatcher)</code> , not the <code>hasEntry(K key, V value)</code>.</p>
  
  <p>Should I just give up and get the item from the Map and manually inspect each property? Is there a cleaner way?</p>