• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 package org.mockito.stubbing;
6 
7 import org.mockito.Incubating;
8 
9 /**
10  * Generic interface to be used for configuring mock's answer for a single argument invocation that returns nothing.
11  *
12  * Answer specifies an action that is executed when you interact with the mock.
13  * <p>
14  * Example of stubbing a mock with this custom answer:
15  *
16  * <pre class="code"><code class="java">
17  * when(mock.someMethod(anyString())).thenAnswer(new Answer&lt;String&gt;() {
18  *     void answer(String msg) {
19  *         throw new Exception(msg);
20  *     }
21  * });
22  *
23  * //Following will raise an exception with the message "boom"
24  * mock.someMethod("boom");
25  * </code></pre>
26  *
27  * @param <A0> type of the single argument
28  * @see Answer
29  */
30 @Incubating
31 public interface VoidAnswer1<A0> {
32     /**
33      * @param argument0 the single argument.
34      *
35      * @throws Throwable the throwable to be thrown
36      */
answer(A0 argument0)37     void answer(A0 argument0) throws Throwable;
38 }
39