DoThrow MailException with mockito
<p>I have a class JavaMailDao that i want to test using JUnit and mockito. I want to test the Catch part</p>

<pre><code>try {
            this.mailSender.send(msg);
    } catch(MailException ex) {
            throw new BackendException(DaoExceptionType.EMAIL_ERROR);
}
</code></pre>

<p>In the test i have this:</p>

<pre><code>Mockito.doNothing().doThrow(new MailException()).when(this.mailSenderMock).send(Mockito.any(SimpleMailMessage.class));
</code></pre>

<p>The problem it's it says : "can't instantiate the type MailException", and i have the import too by the way.</p>

<pre><code>mport org.springframework.mail.MailException;
</code></pre>

<p>Does anyone know how to do it? Thank you!</p>