public void testCreatePlayer() { Player player = new Player(); player.setName("name"); player.setType("type"); player.setUsername("username"); player.setIpAddress("ipaddress"); player.setDynamicIp(false); player.setAutoControlEnabled(false); player.setTechnology(PlayerTechnology.EXTERNAL_WITH_PLAYLIST); player.setClientId("android"); player.setLastSeen(new Date()); player.setTranscodeScheme(TranscodeScheme.MAX_160); playerDao.createPlayer(player); Player newPlayer = playerDao.getAllPlayers().get(0); assertPlayerEquals(player, newPlayer); Player newPlayer2 = playerDao.getPlayerById(newPlayer.getId()); assertPlayerEquals(player, newPlayer2); }
public void testUpdatePlayer() { Player player = new Player(); playerDao.createPlayer(player); assertPlayerEquals(player, playerDao.getAllPlayers().get(0)); player.setName("name"); player.setType("Winamp"); player.setTechnology(PlayerTechnology.WEB); player.setClientId("foo"); player.setUsername("username"); player.setIpAddress("ipaddress"); player.setDynamicIp(true); player.setAutoControlEnabled(false); player.setLastSeen(new Date()); player.setTranscodeScheme(TranscodeScheme.MAX_160); playerDao.updatePlayer(player); Player newPlayer = playerDao.getAllPlayers().get(0); assertPlayerEquals(player, newPlayer); }
public void testGetPlayersForUserAndClientId() { Player player = new Player(); player.setUsername("sindre"); playerDao.createPlayer(player); player = playerDao.getAllPlayers().get(0); List<Player> players = playerDao.getPlayersForUserAndClientId("sindre", null); assertFalse("Error in getPlayersForUserAndClientId().", players.isEmpty()); assertPlayerEquals(player, players.get(0)); assertTrue( "Error in getPlayersForUserAndClientId().", playerDao.getPlayersForUserAndClientId("sindre", "foo").isEmpty()); player.setClientId("foo"); playerDao.updatePlayer(player); players = playerDao.getPlayersForUserAndClientId("sindre", null); assertTrue("Error in getPlayersForUserAndClientId().", players.isEmpty()); players = playerDao.getPlayersForUserAndClientId("sindre", "foo"); assertFalse("Error in getPlayersForUserAndClientId().", players.isEmpty()); assertPlayerEquals(player, players.get(0)); }