Search in sources :

Example 1 with Answer5

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

the class StubbingWithAdditionalAnswersTest method can_return_based_on_strongly_typed_five_parameter_function.

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

        public String answer(String s1, Integer i1, Integer i2, Integer i3, Integer i4) {
            target.simpleMethod(s1, i1, i2, i3, i4);
            return "answered";
        }
    }));
    assertThat(iMethods.simpleMethod("hello", 1, 2, 3, 4)).isEqualTo("answered");
    verify(target, times(1)).simpleMethod("hello", 1, 2, 3, 4);
}
Also used : Answer5(org.mockito.stubbing.Answer5) 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 Answer5 (org.mockito.stubbing.Answer5)1 VoidAnswer5 (org.mockito.stubbing.VoidAnswer5)1 IMethods (org.mockitousage.IMethods)1