title: Using Mockito to mock classes with generic parameters
body: <p>Is there a clean method of mocking a class with generic parameters?  Say I have to mock a class <code>Foo&lt;T&gt;</code> which I need to pass into a method that expects a <code>Foo&lt;Bar&gt;</code>.  I can do the following easily enough:</p>
  
  <pre><code>Foo mockFoo = mock(Foo.class);
  when(mockFoo.getValue).thenReturn(new Bar());
  </code></pre>
  
  <p>Assuming <code>getValue()</code> returns the generic type <code>T</code>.  But that's going to have kittens when I later pass it into a method expecting <code>Foo&lt;Bar&gt;</code>.  Is casting the only means of doing this?</p>