• 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  * import static org.mockito.AdditionalAnswers.answerVoid;
18  *
19  * doAnswer(answerVoid(
20  *     new VoidAnswer1&lt;String&gt;() {
21  *         public void answer(String msg) throws Exception {
22  *             throw new Exception(msg);
23  *         }
24  * })).when(mock).someMethod(anyString());
25  *
26  * //Following will raise an exception with the message "boom"
27  * mock.someMethod("boom");
28  * </code></pre>
29  *
30  * @param <A0> type of the single argument
31  * @see Answer
32  */
33 @Incubating
34 public interface VoidAnswer1<A0> {
35     /**
36      * @param argument0 the single argument.
37      *
38      * @throws Throwable the throwable to be thrown
39      */
answer(A0 argument0)40     void answer(A0 argument0) throws Throwable;
41 }
42