title: Mockito not recognizing my mocked class when passing through when()
body: <p>I want the <code>closeSession()</code> method to throw an Exception when it is called so that I can test to see my logging is being done. I have mocked the <code>Crypto</code> object as <code>mockCrypto</code> and set it up as follows: </p>
  
  <pre><code>@Test
    public void testdecrpyMcpDataExceptions() throws Exception {
      Crypto mockCrypto = Mockito.mock(Crypto.class);
        try {
              mockCrypto = CryptoManager.getCrypto();
              logger.info("Cyrpto Initialized");
        } finally {
              logger.info("Finally");
              try {
                  logger.info("About to close Crypto!");
                  Mockito.doThrow(new CryptoException("")).when(mockCrypto).closeSession();
                  mockCrypto.closeSession();
                  } catch (CryptoException e) {
                      logger.warn("CryptoException occurred when closing crypto session at decryptMcpData() in CipherUtil : esi");
  
                  }
              }
      }
  </code></pre>
  
  <p>However when I run it I get the error :</p>
  
  <pre><code>Argument passed to when() is not a mock!
  </code></pre>
  
  <p>Am I mocking the class wrong or am I just missing something?</p>