@Test
public void stubMethodAnswer() throws Exception {

    User user = new User(mockWebService, USER_ID, PASSWORD);
    when(mockWebService.isNetworkOffline()).then(new Answer<Boolean>() {
        int index = 0;

        @Override
        public Boolean answer(InvocationOnMock invocation) throws Throwable {
            return index++ % 2 == 0;
        }
    });

    user.login(mockLoginInterface);
    user.login(mockLoginInterface);
    user.login(mockLoginInterface);

    verify(mockWebService, times(1)).login(anyInt(), anyString(), any(Response.class));
}