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 /** 8 * Generic interface to be used for configuring mock's answer for a five argument invocation. 9 * 10 * Answer specifies an action that is executed and a return value that is returned when you interact with the mock. 11 * <p> 12 * Example of stubbing a mock with this custom answer: 13 * 14 * <pre class="code"><code class="java"> 15 * import static org.mockito.AdditionalAnswers.answer; 16 * 17 * when(mock.someMethod(anyInt(), anyString(), anyChar(), any(), anyBoolean())).then(answer( 18 * new Answer5<StringBuilder, Integer, String, Character, Object, Boolean>() { 19 * public StringBuilder answer(Integer i, String s, Character c, Object o, Boolean isIt) { 20 * return new StringBuilder().append(i).append(s).append(c).append(o.hashCode()).append(isIt); 21 * } 22 * })); 23 * 24 * //Following will print a string like "3xyz131635550true" 25 * System.out.println(mock.someMethod(3, "xy", 'z', new Object(), true)); 26 * </code></pre> 27 * 28 * @param <T> return type 29 * @param <A0> type of the first argument 30 * @param <A1> type of the second argument 31 * @param <A2> type of the third argument 32 * @param <A3> type of the fourth argument 33 * @see Answer 34 */ 35 public interface Answer5<T, A0, A1, A2, A3, A4> { 36 /** 37 * @param argument0 the first argument. 38 * @param argument1 the second argument. 39 * @param argument2 the third argument. 40 * @param argument3 the fourth argument. 41 * @param argument4 the fifth argument. 42 * 43 * @return the value to be returned. 44 * 45 * @throws Throwable the throwable to be thrown 46 */ answer(A0 argument0, A1 argument1, A2 argument2, A3 argument3, A4 argument4)47 T answer(A0 argument0, A1 argument1, A2 argument2, A3 argument3, A4 argument4) throws Throwable; 48 } 49