title: Mockito - Wanted but not invoked: Actually, there were zero interactions with this mock
body: <p>I know there are already at least two same questions asked, but I still can't figure out why I am getting the exception.
  I need to unit test this method:</p>
  
  <pre><code>void setEyelet(final PdfWriter printPdf, final float posX, final float posY) {
  
      InputStream is = WithDefinitions.class.getResourceAsStream(RES_EYELET); //RES_EYELET is a pdf.
      PdfContentByte canvas = printPdf.getDirectContent();
  
      PdfReader reader = new PdfReader(is);
      PdfImportedPage page = printPdf.getImportedPage(reader, 1);
      canvas.addTemplate(page, posX, posY);
      reader.close();
  }
  </code></pre>
  
  <p>and verify that </p>
  
  <pre><code>canvas.addTemplate(page, posX, posY); 
  </code></pre>
  
  <p>was called.</p>
  
  <p>This method is nested in an another method:</p>
  
  <pre><code>void computeEyelets(final PdfWriter printPdf) {
          float lineLeft = borderLeft + EYELET_MARGIN;
          float lineRight = printPdfWidth - borderRight - EYELET_MARGIN - EYELET_SIZE;
          float lineTop = printPdfHeight - borderTop - EYELET_MARGIN - EYELET_SIZE;
          float lineBottom = borderBottom + EYELET_MARGIN;
          float eyeletDistMinH = 20;
          if (eyeletDistMinH != 0 || eyeletDistMinV != 0) {
           setEyelet(printPdf, lineLeft, lineBottom);
      }
  </code></pre>
  
  <p>And finally my unit test code:</p>
  
  <pre><code>public void computeEyeletsNoMirror() {
      PdfWriter pdfWriter = Mockito.mock(PdfWriter.class);
      PdfContentByte pdfContentByte = Mockito.mock(PdfContentByte.class);
      Mockito.when(pdfWriter.getDirectContent()).thenReturn(pdfContentByte);
      WithDefinitions withDefinitions = Mockito.mock(WithDefinitions.class);
      float lineLeft = BORDER_LEFT + EYELET_MARGIN;
      float lineBottom = BORDER_BOTTOM + EYELET_MARGIN;
  
      withDefinitions.setEyeletDistMinH(20);
      withDefinitions.setEyeletDistMinV(20);
      withDefinitions.setMirror(false);
  
      withDefinitions.computeEyelets(pdfWriter);
  
      Mockito.verify(pdfContentByte).addTemplate(
          Mockito.any(PdfImportedPage.class),
          Mockito.eq(lineLeft),
          Mockito.eq(lineBottom)
      );
  </code></pre>
  
  <p>I have no final methods, I use mocked pdf writer as a parameter. What do I need else to do to get the test passing?</p>
  
  <p><strong>UPDATE</strong>
  Below is the exception message:</p>
  
  <pre><code>Wanted but not invoked:
   pdfContentByte.addTemplate(
    &lt;any&gt;,
    62.36221,
    62.36221
  );
  -&gt; at ...tools.pdf.superimpose.WithDefinitionsTest.computeEyeletsNoMirror(WithDefinitionsTest.java:336)
  Actually, there were zero interactions with this mock.
  </code></pre>
  
  <p><strong>UPDATE 2</strong>
  After replacing the mocked WithDefinitions object with the real instance I get the following output:</p>
  
  <pre><code>Argument(s) are different! Wanted:
  pdfContentByte.addTemplate(
    &lt;any&gt;,
    62.36221,
    62.36221
  );
  -&gt; at ...tools.pdf.superimpose.WithDefinitionsTest.computeEyeletsNoMirror(WithDefinitionsTest.java:336)
  Actual invocation has different arguments:
  pdfContentByte.addTemplate(
    null,
    48.18898,
    48.18898
  );
  -&gt; at ...tools.pdf.superimpose.WithDefinitions.setEyelet(WithDefinitions.java:850)
  </code></pre>