Package se.despotify.domain.media

Examples of se.despotify.domain.media.Playlist$PK


    }

    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


    }

    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

    String playlistName = randomPlaylistName();

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

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

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

    reset();

    manager.send(new LoadUserPlaylists(store, user));
    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 = (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


    // 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"));
    manager.send(new LoadPlaylist(store, playlist));

    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

    }

    System.out.println("loaded content of user playlists");

    for (int i = user.getPlaylists().getItems().size() - 1; i >= 0; i--) {
      Playlist playlist = user.getPlaylists().getItems().get(i);
      if (playlist.getName().startsWith("despotify_Test")) {
        new RemovePlaylistFromUser(store, user, playlist).send(manager);
      }
    }
  }
View Full Code Here

        2339641349l,
        1904484306l,
        3794544626l,
    };

    Playlist playlist = new Playlist(Hex.toBytes("473e7d4eef45cd4fa3ee2aaf96c01688"));
    playlist.setName("de");
   
    playlist.setTracks(new ArrayList<Track>(3));
         
    boolean fail = false;
    for (int i = 0; i < defaultTracks.length; i++) {
      playlist.getTracks().clear();
      for (int i2 = 0; i2 <= i; i2++) {
        playlist.getTracks().add((defaultTracks[i2]));
      }
      if (checksums[i] == playlist.calculateChecksum()) {
//        System.out.println("passing test" + i);
      } else {
        System.out.println("!! failing test " + i + ", calculated " + playlist.calculateChecksum() + " != expected " + checksums[i]);
        fail = true;
      }

    }
View Full Code Here

    3e31323430353335 3031373c2f74696d 653e3c757365723e 6b656e742e66696e [>1240535017</time><user>kent.fin]
    656c6c3c2f757365 723e3c2f6368616e 67653e3c76657273 696f6e3e30303030 [ell</user></change><version>0000]
    3030303030362c30 3030303030303030 312c313032363232 393836362c303c2f [000006,0000000001,1026229866,0</]
    76657273696f6e3e                                                    [version>]
     */
    user.getPlaylists().getItems().add(new Playlist("kent.finell", "5667962d4c1764d12cd68b86a4394916", "jotify1", false));
    assertEquals(1026229866l, user.getPlaylists().calculateChecksum());

    /*
    3600cd0000fd5119 3b39429813002885 0a1a72bb7f020000 000000000000ffff [6?????Q?;9B???(???r?????????????]
    ffff01033c69642d 69732d756e697175 652f3e3c6368616e 67653e3c6f70733e [????<id-is-unique/><change><ops>]
    3c6372656174652f 3e3c6e616d653e6a 6f74696679323c2f 6e616d653e3c2f6f [<create/><name>jotify2</name></o]
    70733e3c74696d65 3e31323430353335 3130353c2f74696d 653e3c757365723e [ps><time>1240535105</time><user>]
    6b656e742e66696e 656c6c3c2f757365 723e3c2f6368616e 67653e3c76657273 [kent.finell</user></change><vers]
    696f6e3e30303030 3030303030312c30 3030303030303030 302c303030303030 [ion>0000000001,0000000000,000000]
    303030312c303c2f 76657273696f6e3e                                   [0001,0</version>]

    3600e50000000000 0000000000000000 0000000000000000 0006000000013d2b [6?????????????????????????????=+]
    066a00033c636861 6e67653e3c6f7073 3e3c6164643e3c69 3e313c2f693e3c69 [?j??<change><ops><add><i>1</i><i]
    74656d733e666435 3131393362333934 3239383133303032 3838353061316137 [tems>fd51193b394298130028850a1a7]
    326262376630323c 2f6974656d733e3c 2f6164643e3c2f6f 70733e3c74696d65 [2bb7f02</items></add></ops><time]
    3e31323430353335 3130353c2f74696d 653e3c757365723e 6b656e742e66696e [>1240535105</time><user>kent.fin]
    656c6c3c2f757365 723e3c2f6368616e 67653e3c76657273 696f6e3e30303030 [ell</user></change><version>0000]
    3030303030372c30 3030303030303030 322c333730313437 363237332c303c2f [000007,0000000002,3701476273,0</]
    76657273696f6e3e                                                    [version>]
     */
    user.getPlaylists().getItems().add(new Playlist("kent.finell", "fd51193b394298130028850a1a72bb7f", "jotify2", false));
    assertEquals(3701476273l, user.getPlaylists().calculateChecksum());


    /*
    3600cd00005710e6 6cde8a35bfa824d5 6f85fdab31020000 000000000000ffff [6????W??l??5??$?o???1???????????]
    ffff01033c69642d 69732d756e697175 652f3e3c6368616e 67653e3c6f70733e [????<id-is-unique/><change><ops>]
    3c6372656174652f 3e3c6e616d653e6a 6f74696679333c2f 6e616d653e3c2f6f [<create/><name>jotify3</name></o]
    70733e3c74696d65 3e31323430353335 3134383c2f74696d 653e3c757365723e [ps><time>1240535148</time><user>]
    6b656e742e66696e 656c6c3c2f757365 723e3c2f6368616e 67653e3c76657273 [kent.finell</user></change><vers]
    696f6e3e30303030 3030303030312c30 3030303030303030 302c303030303030 [ion>0000000001,0000000000,000000]
    303030312c303c2f 76657273696f6e3e                                   [0001,0</version>]

    3600e50000000000 0000000000000000 0000000000000000 000700000002dca0 [6???????????????????????????????]
    0bb100033c636861 6e67653e3c6f7073 3e3c6164643e3c69 3e323c2f693e3c69 [????<change><ops><add><i>2</i><i]
    74656d733e353731 3065363663646538 6133356266613832 3464353666383566 [tems>5710e66cde8a35bfa824d56f85f]
    646162333130323c 2f6974656d733e3c 2f6164643e3c2f6f 70733e3c74696d65 [dab3102</items></add></ops><time]
    3e31323430353335 3134383c2f74696d 653e3c757365723e 6b656e742e66696e [>1240535148</time><user>kent.fin]
    656c6c3c2f757365 723e3c2f6368616e 67653e3c76657273 696f6e3e30303030 [ell</user></change><version>0000]
    3030303030382c30 3030303030303030 332c343035313337 353135382c303c2f [000008,0000000003,4051375158,0</]
    76657273696f6e3e                                                    [version>]
     */
    user.getPlaylists().getItems().add(new Playlist("kent.finell", "5710e66cde8a35bfa824d56f85fdab31", "jotify3", false));
    assertEquals(4051375158l, user.getPlaylists().calculateChecksum());


  }
View Full Code Here

    }

    System.out.println("loaded content of user playlists");

    for (int i = user.getPlaylists().getItems().size() - 1; i >= 0; i--) {
      Playlist playlist = user.getPlaylists().getItems().get(i);
      if (playlist.getName().startsWith("despotify_Test")) {
        manager.send(new RemovePlaylistFromUser(store, user, playlist));
      }
    }
  }
View Full Code Here


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

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

    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");
      new AddTrackToPlaylist(store, user, playlist, defaultTracks[i], null).send(manager);
      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");
      new RemoveTrackFromPlaylist(store, user, playlist, i).send(manager);
      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

TOP

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

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.