title: Using hamcrest to match Map contains entries of different types
body: <p>Let's say I have a Map:</p>
  
  <pre><code>Map&lt;String,Object&gt; map1 = new HashMap&lt;String,Object&gt;();
  map1.put("foo1","foo1");
  map1.put("foo2", Arrays.asList("foo2","bar2"));
  </code></pre>
  
  <p>Now I'd like to use Hamcrest matchers to verify the Map's values. If this were a Map&lt; String,String > I would do something similar to this:</p>
  
  <pre><code>assertThat(map1, hasEntry("foo1", "foo1"));
  </code></pre>
  
  <p>However, I'm stuck when trying to use this with Map where the entries in the Map could be a String or a List of values. This works for the first entry:</p>
  
  <pre><code>assertThat(map1, hasEntry("foo1", (Object)"foo1"));
  </code></pre>
  
  <p>For the second entry I can't figure out how to setup the Matchers.</p>
  
  <p>EDIT:</p>
  
  <p>I also tried this, but it produces a compiler warning.</p>
  
  <pre><code>assertThat(
              map1,
              hasEntry(
                      "foo2",
                      contains(hasProperty("name", is("foo2")),
                              hasProperty("name", is("bar2")))));
  </code></pre>
  
  <p>"The method assertThat(T, Matcher) in the type Assert is not applicable for the arguments (Map, Matcher>>>)"</p>
  
  <p>(The above was the solution here: <a href="https://stackoverflow.com/questions/21624592/hamcrest-compare-collections">Hamcrest compare collections</a> )</p>