Package se.despotify.domain.media

Examples of se.despotify.domain.media.Playlist


    String playlistName = randomPlaylistName();

    new LoadUserPlaylists(store, user).send(manager);
    int originalSize = user.getPlaylists().getItems().size();

    Playlist playlist = new CreatePlaylist(store, user, playlistName, false).send(manager);
    assertEquals(originalSize + 1, user.getPlaylists().getItems().size());
    assertTrue(user.getPlaylists().getItems().contains(playlist));

    new RemovePlaylistFromUser(store, user, playlist).send(manager);
    assertEquals(originalSize, user.getPlaylists().getItems().size());
    assertFalse(user.getPlaylists().getItems().contains(playlist));

    reset();

    new LoadUserPlaylists(store, user).send(manager);
    assertEquals(originalSize, user.getPlaylists().getItems().size());
    for (Playlist playlist2 : user.getPlaylists()) {
      assertNotSame(playlist.getByteUUID(), playlist2.getByteUUID());
    }
   

    // todo can we still load it?
View Full Code Here


    String playlistName = randomPlaylistName();

    log.info("\n\n\n\n\n\n\n           create playlist named "+playlistName+"\n\n\n\n\n\n\n\n\n");

    Playlist originalPlaylist = new CreatePlaylist(new MemoryStore(), user, playlistName, false).send(manager);

    log.info("\n\n\n\n\n\n\n           load playlist with UUID "+Hex.toHex(originalPlaylist.getByteUUID())+"\n\n             spotify:user:"+ username + ":playlist:" + SpotifyURI.toURI(Hex.toHex(originalPlaylist.getByteUUID())) +"\n\n\n\n\n\n\n\n\n");

    // brand new store to make sure we dont pick something up from the cache.
    MemoryStore store = new MemoryStore();
    Playlist loadedPlaylist = store.getPlaylist(originalPlaylist.getByteUUID());
    new LoadPlaylist(store, loadedPlaylist).send(manager);

    assertTrue("different stores means different instances", loadedPlaylist != originalPlaylist);
    assertEquals(loadedPlaylist.getChecksum().longValue(), loadedPlaylist.calculateChecksum());
    assertEquals(originalPlaylist.getId(), loadedPlaylist.getId());
    // todo assert the rest


    // todo add playlist at top position
  }
View Full Code Here


  @Test
  public void test() throws Exception {

    Playlist playlist;

//    try {
//      // this playlist contains a bad checksum
//      playlist = (Playlist) SpotifyURL.browse("spotify:user:kent.finell:playlist:6Odybr7gR4L9LwO8dBgBwS", store, connection);
//      fail("Bad checksum in playlist, should not be valid.");
//    } catch (Exception e) {
//      e.printStackTrace();
//    }


//    MediaTestCaseGenerator.createEqualsTest((Playlist)SpotifyURL.browse("spotify:user:kent.finell:playlist:6wvPFkLGKOVl1v3qRJD6HX", connection));

    playlist = store.getPlaylist(SpotifyURI.toHex("6wvPFkLGKOVl1v3qRJD6HX"));
    new LoadPlaylist(store, playlist).send(manager);

    assertEquals("despotify apriori", playlist.getName());  
    assertEquals(7l, playlist.getRevision().longValue());
    assertEquals(3794544626l, playlist.getChecksum().longValue());
    assertEquals(3794544626l, playlist.calculateChecksum());
    assertEquals("kent.finell", playlist.getAuthor());
    assertFalse(playlist.isCollaborative());
    assertEquals("d65f21be4a744a88ea67d8a83c7a2eb5", playlist.getId());
    assertEquals(5, playlist.getTracks().size());

    assertEquals("93f98ea75b4748f797668485a3d01bd0", playlist.getTracks().get(0).getId());
    assertEquals("spotify:track:4vdV2Eua6RkUoUM51jdH56", playlist.getTracks().get(0).getSpotifyURI());
    assertEquals("http://open.spotify.com/track/4vdV2Eua6RkUoUM51jdH56", playlist.getTracks().get(0).getHttpURL());
    assertNull(playlist.getTracks().get(0).getTitle());
    assertNull(playlist.getTracks().get(0).getCover());
    assertNull(playlist.getTracks().get(0).getFiles());
    assertNull(playlist.getTracks().get(0).getLength());
    assertNull(playlist.getTracks().get(0).getPopularity());
    assertNull(playlist.getTracks().get(0).getTrackNumber());
    assertNull(playlist.getTracks().get(0).getYear());

    assertEquals("cf2cd530980e450d855977ba0a80ec6e", playlist.getTracks().get(1).getId());
    assertEquals("spotify:track:6iVTOPCmpABvG9jDZ2JozY", playlist.getTracks().get(1).getSpotifyURI());
    assertEquals("http://open.spotify.com/track/6iVTOPCmpABvG9jDZ2JozY", playlist.getTracks().get(1).getHttpURL());
    assertNull(playlist.getTracks().get(1).getTitle());
    assertNull(playlist.getTracks().get(1).getCover());
    assertNull(playlist.getTracks().get(1).getFiles());
    assertNull(playlist.getTracks().get(1).getLength());
    assertNull(playlist.getTracks().get(1).getPopularity());
    assertNull(playlist.getTracks().get(1).getTrackNumber());
    assertNull(playlist.getTracks().get(1).getYear());

    assertEquals("fc1f1b5860f04a739971fcad9c1cd634", playlist.getTracks().get(2).getId());
    assertEquals("spotify:track:7FKhuZtIPchBVNIhFnNL5W", playlist.getTracks().get(2).getSpotifyURI());
    assertEquals("http://open.spotify.com/track/7FKhuZtIPchBVNIhFnNL5W", playlist.getTracks().get(2).getHttpURL());
    assertNull(playlist.getTracks().get(2).getTitle());
    assertNull(playlist.getTracks().get(2).getCover());
    assertNull(playlist.getTracks().get(2).getFiles());
    assertNull(playlist.getTracks().get(2).getLength());
    assertNull(playlist.getTracks().get(2).getPopularity());
    assertNull(playlist.getTracks().get(2).getTrackNumber());
    assertNull(playlist.getTracks().get(2).getYear());

    assertEquals("7093f50c9ecf428eb780348c076f9f7f", playlist.getTracks().get(3).getId());
    assertEquals("spotify:track:3qqKWUVfiLMrNPacFRzTzh", playlist.getTracks().get(3).getSpotifyURI());
    assertEquals("http://open.spotify.com/track/3qqKWUVfiLMrNPacFRzTzh", playlist.getTracks().get(3).getHttpURL());
    assertNull(playlist.getTracks().get(3).getTitle());
    assertNull(playlist.getTracks().get(3).getCover());
    assertNull(playlist.getTracks().get(3).getFiles());
    assertNull(playlist.getTracks().get(3).getLength());
    assertNull(playlist.getTracks().get(3).getPopularity());
    assertNull(playlist.getTracks().get(3).getTrackNumber());
    assertNull(playlist.getTracks().get(3).getYear());

    assertEquals("48daf12f96f84793a526b579aa4d1f66", playlist.getTracks().get(4).getId());
    assertEquals("spotify:track:2dtvgPd3vsotKXtGk4dWlg", playlist.getTracks().get(4).getSpotifyURI());
    assertEquals("http://open.spotify.com/track/2dtvgPd3vsotKXtGk4dWlg", playlist.getTracks().get(4).getHttpURL());
    assertNull(playlist.getTracks().get(4).getTitle());
    assertNull(playlist.getTracks().get(4).getCover());
    assertNull(playlist.getTracks().get(4).getFiles());
    assertNull(playlist.getTracks().get(4).getLength());
    assertNull(playlist.getTracks().get(4).getPopularity());
    assertNull(playlist.getTracks().get(4).getTrackNumber());
    assertNull(playlist.getTracks().get(4).getYear());


  }
View Full Code Here

  @Override
  public Playlist send(DespotifyManager connectionManager) throws DespotifyException {
    byte[] playlistUUID = new ReserveRandomPlaylistUUID(store, user, playlistName, collaborative).send(connectionManager);
    String hexUUID = Hex.toHex(playlistUUID);
    Playlist playlist = store.getPlaylist(hexUUID);
    playlist.setAuthor(user.getId());
    playlist.setName(playlistName);
    playlist.setId(hexUUID);
    if (new CreatePlaylistWithReservedUUID(store, user, playlist).send(connectionManager)) {
      return (Playlist)store.persist(playlist);
    } else {
      throw new DespotifyException();
    }
View Full Code Here


    manager.send(new LoadUserPlaylists(store, user));
    int playlistsFromStart = user.getPlaylists().getItems().size();

    Playlist playlist = (Playlist)manager.send(new CreatePlaylist(store, user, playlistName, false));

    assertEquals(playlistsFromStart + 1, user.getPlaylists().getItems().size());

    long[] checksums = new long[]{
        1461913864l,
        823267316l,
        2339641349l,
        1904484306l,
        3794544626l,
    };

    for (int i = 0; i < checksums.length; i++) {
      log.info("\n\n\n\n\n\n\n           ADD TRACK " + i + "\n\n\n\n\n\n\n\n\n");
      manager.send(new AddTrackToPlaylist(store, user, playlist, defaultTracks[i], null));
      assertEquals(checksums[i], playlist.calculateChecksum());
      assertEquals(checksums[i], playlist.getChecksum().longValue());
      assertEquals(i + 1, playlist.getTracks().size());
      assertEquals(defaultTracks[i], playlist.getTracks().get(i));

      // todo get list using alternative connection and assert the same

    }

    for (int i = checksums.length; i > 1; i--) {
      log.info("\n\n\n\n\n\n\n           REMOVE TRACK " + i + "\n\n\n\n\n\n\n\n\n");
      manager.send(new RemoveTrackFromPlaylist(store, user, playlist, i));
      assertEquals(checksums[i - 2], playlist.calculateChecksum());
      assertEquals(checksums[i - 2], playlist.getChecksum().longValue());
      assertEquals(i - 1, playlist.getTracks().size());

      // todo get list using alternative connection and assert the same

    }
View Full Code Here

    String playlistName = randomPlaylistName();

    log.info("\n\n\n\n\n\n\n           create playlist named "+playlistName+"\n\n\n\n\n\n\n\n\n");

    Playlist originalPlaylist = (Playlist)manager.send(new CreatePlaylist(new MemoryStore(), user, playlistName, false));

    log.info("\n\n\n\n\n\n\n           load playlist with UUID "+Hex.toHex(originalPlaylist.getByteUUID())+"\n\n             spotify:user:"+ username + ":playlist:" + SpotifyURI.toURI(Hex.toHex(originalPlaylist.getByteUUID())) +"\n\n\n\n\n\n\n\n\n");

    // brand new store to make sure we dont pick something up from the cache.
    MemoryStore store = new MemoryStore();
    Playlist loadedPlaylist = store.getPlaylist(originalPlaylist.getByteUUID());
    manager.send(new LoadPlaylist(store, loadedPlaylist));

    assertTrue("different stores means different instances", loadedPlaylist != originalPlaylist);
    assertEquals(loadedPlaylist.getChecksum().longValue(), loadedPlaylist.calculateChecksum());
    assertEquals(originalPlaylist.getId(), loadedPlaylist.getId());
    // todo assert the rest

  }
View Full Code Here

    }

    XMLElement reponseElement = XML.load(xml);

    if (reponseElement.hasChild("confirm")) {
      Playlist playlist = store.getPlaylist(requestedPlaylistUUID);
      playlist.setName(playlistName);
      playlist.setCollaborative(collaborative);     
      return true;
    } else {
      log.warn("Invalid response when requesting UUID " + Hex.toHex(requestedPlaylistUUID) + ":\n" + xml);
      return false;
    }
View Full Code Here

TOP

Related Classes of se.despotify.domain.media.Playlist

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.