use of org.mockito.stubbing.Answer4 in project mockito by mockito.
the class StubbingWithAdditionalAnswersTest method can_return_based_on_strongly_typed_four_parameter_function.
@Test
public void can_return_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(answer(new Answer4<String, Integer, String, String, boolean[]>() {
public String answer(Integer i, String s1, String s2, boolean[] a) {
target.fourArgumentMethod(i, s1, s2, a);
return "answered";
}
}));
boolean[] booleanArray = { true, false };
assertThat(iMethods.fourArgumentMethod(1, "string1", "string2", booleanArray)).isEqualTo("answered");
verify(target, times(1)).fourArgumentMethod(1, "string1", "string2", booleanArray);
}
Aggregations