use of org.mockito.stubbing.VoidAnswer4 in project mockito by mockito.
the class StubbingWithAdditionalAnswersTest method will_execute_a_void_based_on_strongly_typed_four_parameter_function.
@Test
public void will_execute_a_void_based_on_strongly_typed_four_parameter_function() throws Exception {
final IMethods target = mock(IMethods.class);
given(iMethods.fourArgumentMethod(anyInt(), anyString(), anyString(), any(boolean[].class))).will(answerVoid(new VoidAnswer4<Integer, String, String, boolean[]>() {
public void answer(Integer i, String s1, String s2, boolean[] a) {
target.fourArgumentMethod(i, s1, s2, a);
}
}));
// invoke on iMethods
boolean[] booleanArray = { true, false };
iMethods.fourArgumentMethod(1, "string1", "string2", booleanArray);
// expect the answer to write correctly to "target"
verify(target, times(1)).fourArgumentMethod(1, "string1", "string2", booleanArray);
}
Aggregations