Search in sources :

Example 1 with VoidAnswer4

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);
}
Also used : IMethods(org.mockitousage.IMethods) VoidAnswer4(org.mockito.stubbing.VoidAnswer4) BDDMockito.anyString(org.mockito.BDDMockito.anyString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 BDDMockito.anyString (org.mockito.BDDMockito.anyString)1 VoidAnswer4 (org.mockito.stubbing.VoidAnswer4)1 IMethods (org.mockitousage.IMethods)1