LogoutDelegator extends BaseDelegator implements ILogoutDelegator { @Override public void logout() throws ConnectionException, RequestException, AccessException, ConfigException { try { logout(new LoginOptions()); } catch (final ConnectionException | AccessException | RequestException exc) { throw exc; } catch (P4JavaException exc) { throw new RequestException(exc.getMessage(), exc); } } LogoutDelegator(final IOptionsServer server); @Override void logout(); @Override void logout(final LoginOptions opts);  }
@Test(expected = AccessException.class) public void testLogoutAccessException() throws P4JavaException { setUp(AccessException.AccessExceptionForTests.class); logoutDelegator.logout(); }
@Test(expected = AccessException.class) public void testLogoutOptAccessException() throws P4JavaException { setUp(AccessException.AccessExceptionForTests.class); logoutDelegator.logout(null); }
@Test public void testLogout() throws P4JavaException { when(server.execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq((Map<String, Object>)null))) .thenReturn(null); when(server.getAuthTicket()).thenReturn("auth"); logoutDelegator.logout(); verify(server).execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq((Map<String, Object>)null)); verify(server).setAuthTicket(null); verify(server).getAuthTicket(); }
@Test public void testLogoutOpt() throws P4JavaException { when(server.execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq((Map<String, Object>)null))) .thenReturn(null); when(server.getAuthTicket()).thenReturn("auth"); logoutDelegator.logout(new LoginOptions()); verify(server).execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq((Map<String, Object>)null)); verify(server).setAuthTicket(null); verify(server).getAuthTicket(); }
@Test(expected = ConnectionException.class) public void testLogoutConnectionException() throws P4JavaException { setUp(ConnectionException.class); logoutDelegator.logout(); }
@Test(expected = AccessException.class) public void testLogoutAccessException() throws P4JavaException { setUp(AccessException.class); logoutDelegator.logout(); }
@Test(expected = RequestException.class) public void testLogoutRequestException() throws P4JavaException { setUp(RequestException.class); logoutDelegator.logout(); }
@Test(expected = P4JavaException.class) public void testLogoutP4JavaException() throws P4JavaException { setUp(P4JavaException.class); logoutDelegator.logout(); }
@Test(expected = ConnectionException.class) public void testLogoutOptConnectionException() throws P4JavaException { setUp(ConnectionException.class); logoutDelegator.logout(null); }
@Test(expected = AccessException.class) public void testLogoutOptAccessException() throws P4JavaException { setUp(AccessException.class); logoutDelegator.logout(null); }
@Test(expected = RequestException.class) public void testLogoutOptRequestException() throws P4JavaException { setUp(RequestException.class); logoutDelegator.logout(null); }
@Test(expected = P4JavaException.class) public void testLogoutOptP4JavaException() throws P4JavaException { setUp(P4JavaException.class); logoutDelegator.logout(null); }
@Test public void testLogout() throws P4JavaException { when(server.execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenReturn(null); when(server.getAuthTicket()).thenReturn("auth"); logoutDelegator.logout(); verify(server).execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq(null)); verify(server).setAuthTicket(null); verify(server).getAuthTicket(); }
@Test public void testLogoutOpt() throws P4JavaException { when(server.execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenReturn(null); when(server.getAuthTicket()).thenReturn("auth"); logoutDelegator.logout(new LoginOptions()); verify(server).execMapCmdList(eq(LOGOUT.toString()), argThat(EMPTY_MATCHER), eq(null)); verify(server).setAuthTicket(null); verify(server).getAuthTicket(); }