Search in sources :

Example 1 with Player

use of org.libresonic.player.domain.Player in project libresonic by Libresonic.

the class PlayerDaoTestCase method testGetPlayersForUserAndClientId.

@Test
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));
}
Also used : Player(org.libresonic.player.domain.Player) Test(org.junit.Test)

Example 2 with Player

use of org.libresonic.player.domain.Player in project libresonic by Libresonic.

the class PlayerDaoTestCase method testIdentity.

@Test
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());
}
Also used : Player(org.libresonic.player.domain.Player) Test(org.junit.Test)

Example 3 with Player

use of org.libresonic.player.domain.Player in project libresonic by Libresonic.

the class PlayerDaoTestCase method testPlaylist.

@Test
public void testPlaylist() {
    Player player = new Player();
    playerDao.createPlayer(player);
    PlayQueue playQueue = player.getPlayQueue();
    assertNotNull("Missing playlist.", playQueue);
    playerDao.deletePlayer(player.getId());
    playerDao.createPlayer(player);
    assertNotSame("Wrong playlist.", playQueue, player.getPlayQueue());
}
Also used : Player(org.libresonic.player.domain.Player) PlayQueue(org.libresonic.player.domain.PlayQueue) Test(org.junit.Test)

Example 4 with Player

use of org.libresonic.player.domain.Player in project libresonic by Libresonic.

the class TranscodingDaoTestCase method testCascadingDeleteTranscoding.

@Test
public void testCascadingDeleteTranscoding() {
    Player player = new Player();
    playerDao.createPlayer(player);
    transcodingDao.createTranscoding(new Transcoding(null, "name", "sourceFormats", "targetFormat", "step1", "step2", "step3", true));
    Transcoding transcoding = transcodingDao.getAllTranscodings().get(0);
    transcodingDao.setTranscodingsForPlayer(player.getId(), new int[] { transcoding.getId() });
    List<Transcoding> activeTranscodings = transcodingDao.getTranscodingsForPlayer(player.getId());
    assertEquals("Wrong number of transcodings.", 1, activeTranscodings.size());
    transcodingDao.deleteTranscoding(transcoding.getId());
    activeTranscodings = transcodingDao.getTranscodingsForPlayer(player.getId());
    assertEquals("Wrong number of transcodings.", 0, activeTranscodings.size());
}
Also used : Player(org.libresonic.player.domain.Player) Transcoding(org.libresonic.player.domain.Transcoding) Test(org.junit.Test)

Example 5 with Player

use of org.libresonic.player.domain.Player in project libresonic by Libresonic.

the class TranscodingDaoTestCase method testCascadingDeletePlayer.

@Test
public void testCascadingDeletePlayer() {
    Player player = new Player();
    playerDao.createPlayer(player);
    transcodingDao.createTranscoding(new Transcoding(null, "name", "sourceFormats", "targetFormat", "step1", "step2", "step3", true));
    Transcoding transcoding = transcodingDao.getAllTranscodings().get(0);
    transcodingDao.setTranscodingsForPlayer(player.getId(), new int[] { transcoding.getId() });
    List<Transcoding> activeTranscodings = transcodingDao.getTranscodingsForPlayer(player.getId());
    assertEquals("Wrong number of transcodings.", 1, activeTranscodings.size());
    playerDao.deletePlayer(player.getId());
    activeTranscodings = transcodingDao.getTranscodingsForPlayer(player.getId());
    assertEquals("Wrong number of transcodings.", 0, activeTranscodings.size());
}
Also used : Player(org.libresonic.player.domain.Player) Transcoding(org.libresonic.player.domain.Transcoding) Test(org.junit.Test)

Aggregations

Player (org.libresonic.player.domain.Player)25 Test (org.junit.Test)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 MediaFile (org.libresonic.player.domain.MediaFile)4 User (org.libresonic.player.domain.User)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Transcoding (org.libresonic.player.domain.Transcoding)3 File (java.io.File)2 PlayQueue (org.libresonic.player.domain.PlayQueue)2 Playlist (org.libresonic.player.domain.Playlist)2 TransferStatus (org.libresonic.player.domain.TransferStatus)2 UserSettings (org.libresonic.player.domain.UserSettings)2 RedirectView (org.springframework.web.servlet.view.RedirectView)2 PrintWriter (java.io.PrintWriter)1 DateFormat (java.text.DateFormat)1 Cookie (javax.servlet.http.Cookie)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1