Search in sources :

Example 1 with Answer4

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);
}
Also used : Answer4(org.mockito.stubbing.Answer4) VoidAnswer4(org.mockito.stubbing.VoidAnswer4) 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 Answer4 (org.mockito.stubbing.Answer4)1 VoidAnswer4 (org.mockito.stubbing.VoidAnswer4)1 IMethods (org.mockitousage.IMethods)1