public void testIdentity() { Player player = new Player(); playerDao.createPlayer(player); assertEquals("Wrong ID", "1", player.getId()); assertEquals("Wrong number of players.", 1, playerDao.getAllPlayers().size()); playerDao.createPlayer(player); assertEquals("Wrong ID", "2", player.getId()); assertEquals("Wrong number of players.", 2, playerDao.getAllPlayers().size()); playerDao.createPlayer(player); assertEquals("Wrong ID", "3", player.getId()); assertEquals("Wrong number of players.", 3, playerDao.getAllPlayers().size()); playerDao.deletePlayer("3"); playerDao.createPlayer(player); assertEquals("Wrong ID", "3", player.getId()); assertEquals("Wrong number of players.", 3, playerDao.getAllPlayers().size()); playerDao.deletePlayer("2"); playerDao.createPlayer(player); assertEquals("Wrong ID", "4", player.getId()); assertEquals("Wrong number of players.", 3, playerDao.getAllPlayers().size()); }
private void assertPlayerEquals(Player expected, Player actual) { assertEquals("Wrong ID.", expected.getId(), actual.getId()); assertEquals("Wrong name.", expected.getName(), actual.getName()); assertEquals("Wrong technology.", expected.getTechnology(), actual.getTechnology()); assertEquals("Wrong client ID.", expected.getClientId(), actual.getClientId()); assertEquals("Wrong type.", expected.getType(), actual.getType()); assertEquals("Wrong username.", expected.getUsername(), actual.getUsername()); assertEquals("Wrong IP address.", expected.getIpAddress(), actual.getIpAddress()); assertEquals("Wrong dynamic IP.", expected.isDynamicIp(), actual.isDynamicIp()); assertEquals( "Wrong auto control enabled.", expected.isAutoControlEnabled(), actual.isAutoControlEnabled()); assertEquals("Wrong last seen.", expected.getLastSeen(), actual.getLastSeen()); assertEquals( "Wrong transcode scheme.", expected.getTranscodeScheme(), actual.getTranscodeScheme()); }
public void testPlaylist() { Player player = new Player(); playerDao.createPlayer(player); Playlist playlist = player.getPlaylist(); assertNotNull("Missing playlist.", playlist); playerDao.deletePlayer(player.getId()); playerDao.createPlayer(player); assertNotSame("Wrong playlist.", playlist, player.getPlaylist()); }
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); }
@Override protected ModelAndView handleRequestInternal( HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); String pathInfo = request.getPathInfo(); if (pathInfo == null || !pathInfo.startsWith("/")) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; } Share share = shareService.getShareByName(pathInfo.substring(1)); if (share != null && share.getExpires() != null && share.getExpires().before(new Date())) { share = null; } if (share != null) { share.setLastVisited(new Date()); share.setVisitCount(share.getVisitCount() + 1); shareService.updateShare(share); } Player player = playerService.getGuestPlayer(request); map.put("share", share); map.put("entries", getEntries(share, player)); map.put("redirectUrl", settingsService.getUrlRedirectUrl()); map.put("player", player.getId()); ModelAndView result = super.handleRequestInternal(request, response); result.addObject("model", map); return result; }