title: JUnit - Return a mocked object from a type cast
body: <p>My code looks something like this:</p>
  
  <pre><code>ClassB objB = (ClassB) objA;
  int z = objB.ClassBMethod();
  
  int y = objA.ClassAMethod();
  </code></pre>
  
  <p>Currently my unit test looks like this:</p>
  
  <pre><code>ClassA mockClassA = mock(ClassA.class);
  when(mockClassA.ClassAMethod()).thenReturn(1);
  </code></pre>
  
  <p>How would I mock <code>objA</code>'s cast to <code>ClassB</code> so that I can mock the <code>ClassBMethod()</code>?</p>