Search in sources :

Example 1 with Answer3

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

the class StubbingWithAdditionalAnswersTest method can_return_based_on_strongly_typed_three_parameter_function.

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

        public String answer(Integer i, String s1, String s2) {
            target.threeArgumentMethodWithStrings(i, s1, s2);
            return "answered";
        }
    }));
    assertThat(iMethods.threeArgumentMethodWithStrings(1, "string1", "string2")).isEqualTo("answered");
    verify(target, times(1)).threeArgumentMethodWithStrings(1, "string1", "string2");
}
Also used : VoidAnswer3(org.mockito.stubbing.VoidAnswer3) Answer3(org.mockito.stubbing.Answer3) 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 Answer3 (org.mockito.stubbing.Answer3)1 VoidAnswer3 (org.mockito.stubbing.VoidAnswer3)1 IMethods (org.mockitousage.IMethods)1