title: Mockito: "Wanted but not invoked: [...] Actually, there were zero interactions with this mock."
body: <p>I have gone through posts on StackOverflow.</p>
  
  <blockquote>
    <p>Wanted but not invoked: Actually, there were zero interactions with this mock. </p>
  </blockquote>
  
  <p>I did do what was asked there still I am missing something. Can you please help me what I am missing?</p>
  
  <p>My Java code:</p>
  
  <pre><code>public class AccountController {
  
      public ResponseEntity&lt;AccountResponse&gt; getAccountByAccountId(
              @RequestHeader("Authorization") final String accountToken,
              @PathVariable("accountId") String accountId) {
  
          return accountHandler.apply(() -&gt; {
  
              final AcccountResponse accountResponse = accountService
                      .getAccountByAccountId(accountId);
  
              return ResponseEntity.ok().body(accountResponse);
  
          });
      }
  }
  </code></pre>
  
  <p>My unit test:</p>
  
  <pre><code>@InjectMocks
  private AccountController accountController;
  
  @Mock
  private AccountService accountService;
  
  @Mock
  private AccountHandler accountHandler;
  
  @Captor
  private ArgumentCaptor&lt;Supplier&lt;ResponseEntity&lt;AccountResponse&gt;&gt;&gt; responseAccount;
  
  private static AccountResponse accountResponse;
  
  @Before
  public void setUp() {
  
      responseEntity = ResponseEntity.ok().body(accountResponse);
  }
  
  @Test
  public void getAccountByAccountIdTest() {
  
      when(accountHandler.apply(responseAccount.capture())).thenReturn(responseEntity);
      when(accountService.getAccountByAccountId(accountId)).thenReturn(accountResponse);
  
      ResponseEntity&lt;AccountResponse&gt; accountResult = accountController.getAccountByAccountId(accountToken, accountId);
  
      assertNotNull(accountResult);
      assertEquals(HttpStatus.OK, accountResult.getStatusCode());
      assertSame(accountResponse, accountResult.getBody());
      verify(accountHandler).apply(responseAccount.capture());
      verify(accountService).getAccountByAccountId(accountId); // this fails and gives me error
  }
  </code></pre>
  
  <p>Everything works fine except <code>verify(acccountService).getAccountByAccountId(accountId);</code>
  I get error as </p>
  
  <pre><code>Wanted but not invoked:
  acccountService.getAccountByAccountId(
  
      "accountId"
  );
  Actually, there were zero interactions with this mock.
  </code></pre>