mock.when in mockito code example
Example 1: mockito mock resultset
Mockito.when(resultSetMock.next()).thenReturn(true).thenReturn(false);
Example 2: mockito new Mock()
TestedClass tc = spy(new TestedClass());
LoginContext lcMock = mock(LoginContext.class);
when(tc.login(anyString(), anyString())).thenReturn(lcMock);