title: How to mock nested methods in Java
body: <p>In order to test my program I need to mock a method call like:</p>
  
  <pre><code>entityManager.createQuery("SELECT...", Integer.class).getSingleResult()
  </code></pre>
  
  <p>the <code>createQuery</code> part returns a <code>TypedQuery&lt;Integer&gt;</code>, but I actually just want to return a single integer: 1.
  Currently I am using Mockito in order to create my mocks and I am pretty new to this.</p>
  
  <p>Is there a way of testing this?</p>
  
  <p>Thank you!</p>