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 five 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 VoidAnswer5<String, Integer, String, Character, String>() { 21 * public void answer(String msg, Integer count, String another, Character c, String subject) throws Exception { 22 * throw new Exception(String.format(msg, another, c, count, subject)); 23 * } 24 * })).when(mock).someMethod(anyString(), anyInt(), anyString(), anyChar(), anyString()); 25 * 26 * //Following will raise an exception with the message "ka-boom <3 mockito" 27 * mock.someMethod("%s-boom %c%d %s", 3, "ka", '<', "mockito"); 28 * </code></pre> 29 * 30 * @param <A0> type of the first argument 31 * @param <A1> type of the second argument 32 * @param <A2> type of the third argument 33 * @param <A3> type of the fourth argument 34 * @param <A4> type of the fifth argument 35 * @see Answer 36 */ 37 @Incubating 38 public interface VoidAnswer5<A0, A1, A2, A3, A4> { 39 /** 40 * @param argument0 the first argument. 41 * @param argument1 the second argument. 42 * @param argument2 the third argument. 43 * @param argument3 the fourth argument. 44 * @param argument4 the fifth argument. 45 * 46 * @throws Throwable the throwable to be thrown 47 */ answer(A0 argument0, A1 argument1, A2 argument2, A3 argument3, A4 argument4)48 void answer(A0 argument0, A1 argument1, A2 argument2, A3 argument3, A4 argument4) throws Throwable; 49 } 50