Search in sources :

Example 1 with VoidAnswer5

use of org.mockito.stubbing.VoidAnswer5 in project mockito by mockito.

the class StubbingWithAdditionalAnswersTest method will_execute_a_void_based_on_strongly_typed_five_parameter_function.

@Test
public void will_execute_a_void_based_on_strongly_typed_five_parameter_function() throws Exception {
    final IMethods target = mock(IMethods.class);
    given(iMethods.simpleMethod(anyString(), anyInt(), anyInt(), anyInt(), anyInt())).will(answerVoid(new VoidAnswer5<String, Integer, Integer, Integer, Integer>() {

        public void answer(String s1, Integer i1, Integer i2, Integer i3, Integer i4) {
            target.simpleMethod(s1, i1, i2, i3, i4);
        }
    }));
    // invoke on iMethods
    iMethods.simpleMethod("hello", 1, 2, 3, 4);
    // expect the answer to write correctly to "target"
    verify(target, times(1)).simpleMethod("hello", 1, 2, 3, 4);
}
Also used : VoidAnswer5(org.mockito.stubbing.VoidAnswer5) IMethods(org.mockitousage.IMethods) BDDMockito.anyString(org.mockito.BDDMockito.anyString) Test(org.junit.Test)

Aggregations

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