title: mock a method with generic return type with mockito
body: <p><br>
  Here is my problem:</p>
  
  <pre><code>public interface Containter extends ModelElement{
       List&lt;? extends ModelElement&gt; getChildren();
  }
  </code></pre>
  
  <p>There are several classes implementing Containter, and I want to mock them:</p>
  
  <pre><code>public class MockMama {
     public static &lt;T extends Containter, Y extends ModelElement&gt; T bornContainer(Class&lt;T&gt; clazz, Y ... children) {
             T container = mock(clazz);
             when(container.getChildren()).thenReturn(Arrays.asList(children));
             return container;
     }
  }
  </code></pre>
  
  <p>But this doesn't work. Eclipse says "The method thenReturn(List) in the type OngoingStubbing> is not applicable for the arguments (List)". I've also tried to pass locally declared variable of type  List<code>&lt;? extends ModelElement&gt;</code> to thenReturn but this didn't help either.
  <br> Any help is highly appreciated and welcomed :)</p>