### Question:
AsynchronousLogin implements AsynchronousProcess { public void forceLogin(Player player) { PlayerAuth auth = getPlayerAuth(player); if (auth != null) { performLogin(player, auth); } } AsynchronousLogin(); void login(Player player, String password); void forceLogin(Player player);  }### Answer:
@Test public void shouldNotForceLoginAlreadyLoggedInPlayer() { String name = "bobby"; Player player = mockPlayer(name); given(playerCache.isAuthenticated(name)).willReturn(true); asynchronousLogin.forceLogin(player); verify(playerCache, only()).isAuthenticated(name); verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); verifyZeroInteractions(dataSource); }
@Test public void shouldNotForceLoginNonExistentUser() { String name = "oscar"; Player player = mockPlayer(name); given(playerCache.isAuthenticated(name)).willReturn(false); given(dataSource.getAuth(name)).willReturn(null); asynchronousLogin.forceLogin(player); verify(playerCache, only()).isAuthenticated(name); verify(commonService).send(player, MessageKey.UNKNOWN_USER); verify(dataSource, only()).getAuth(name); }
@Test public void shouldNotForceLoginInactiveUser() { String name = "oscar"; Player player = mockPlayer(name); given(playerCache.isAuthenticated(name)).willReturn(false); int groupId = 13; PlayerAuth auth = PlayerAuth.builder().name(name).groupId(groupId).build(); given(dataSource.getAuth(name)).willReturn(auth); given(commonService.getProperty(DatabaseSettings.MYSQL_COL_GROUP)).willReturn("group"); given(commonService.getProperty(HooksSettings.NON_ACTIVATED_USERS_GROUP)).willReturn(groupId); asynchronousLogin.forceLogin(player); verify(playerCache, only()).isAuthenticated(name); verify(commonService).send(player, MessageKey.ACCOUNT_NOT_ACTIVATED); verify(dataSource, only()).getAuth(name); }