Examples of WSResponse


Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    when(lastFmSettingsService.getLastFmUsers()).thenReturn(asList(user1, user2));
    when(lastFmSettingsService.isSyncStarredAndLovedTracks()).thenReturn(true);

    UserLovedTracksClient userLovedTracksClient = mock(UserLovedTracksClient.class);
    when(userLovedTracksClient.getUserLovedTracks(user1, (short) 0)).thenReturn(
        new WSResponse(new ResourceUtil(LOVED_TRACKS_FILE, UTF8).getContent()));
    when(userLovedTracksClient.getUserLovedTracks(user2, (short) 0)).thenReturn(
        new WSResponse(false, 403, "Forbidden"));

    UserLovedTracksService userLovedTracksService = new UserLovedTracksService();
    userLovedTracksService.setLastFmSettingsService(lastFmSettingsService);
    userLovedTracksService.setUserLovedTracksClient(userLovedTracksClient);
    userLovedTracksService.setUserLovedTracksDao(userLovedTracksDao);
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    scrobbleService = new ScrobbleService();

    UpdateNowPlayingClient nowPlayinglient = mock(UpdateNowPlayingClient.class);
    when(nowPlayinglient.updateNowPlaying(Mockito.any(Scrobble.class))).thenReturn(
        new WSResponse(false, 404, "Not found"));
    scrobbleService.setUpdateNowPlayingClient(nowPlayinglient);

    ScrobbleClient scrobbleClient = mock(ScrobbleClient.class);
    when(scrobbleClient.scrobble(Mockito.any(Scrobble.class))).thenReturn(
        new WSResponse("<lfm status=\"ok\"></lfm>"));
    scrobbleService.setScrobbleClient(scrobbleClient);
   
    PlayCountDao playCountDao = mock(PlayCountDao.class);
    scrobbleService.setPlayCountDao(playCountDao);
   
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

 
  private WSResponse responseOK, responseFail;

  @Before
  public void createTestData() throws ApplicationException {
    responseOK = new WSResponse("<lfm status=\"ok\"></lfm>");
    responseFail = new WSResponse(false, 404, "Not found");
  }
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    UserTopArtistsClient userTopArtistsClient = mock(UserTopArtistsClient.class);
    for (Period period : Period.values()) {
      String fileName = format(TOP_ARTISTS_FILE, period.getDescription());
      when(userTopArtistsClient.getUserTopArtists(user1, period)).thenReturn(
          new WSResponse(new ResourceUtil(fileName, UTF8).getContent()));
      when(userTopArtistsClient.getUserTopArtists(user2, period)).thenReturn(
          new WSResponse(false, 403, "Forbidden"));
    }

    UserTopArtistsService userTopArtistsService = new UserTopArtistsService();
    userTopArtistsService.setLastFmSettingsService(lastFmSettingsService);
    userTopArtistsService.setUserTopArtistsClient(userTopArtistsClient);
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    rjRec = new UserRecommendedArtists(rj,
        new UserRecommendedArtistsParserImpl(new ResourceUtil(
            RJ_FILE).getInputStream()).getArtists());

    String body = new WSResponse(new ResourceUtil(FTPAREA_FILE).getContent()).getResponseBody();
    ftpareaRec = new UserRecommendedArtists(ftparea,
        new UserRecommendedArtistsParserImpl(new StringUtil(
            body).getInputStream()).getArtists());

    createArtistMetaData();
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    }
  }

  @Test
  public void resourceFile2CorrectlyParsed() throws ApplicationException {
    WSResponse wsResponse = new WSResponse(new ResourceUtil(
        USER_RECOMMENDED_ARTISTS_FILE2).getContent());
   
    UserRecommendedArtistsParser parser = new UserRecommendedArtistsParserImpl(
        new StringUtil(wsResponse.getResponseBody()).getInputStream());
    List<RecommendedArtist> artists = parser.getArtists();
   
    for (int i = 0; i < EXPECTED_ARTISTS2.size(); i++) {
      assertEquals(EXPECTED_ARTISTS2.get(i), artists.get(i));
    }
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    List<UserLovedTracks> userLovedTracks = new ArrayList<>();
    for (LastFmUser user : users) {
      short page = 0, totalPages = 0;
      List<Track> lovedTracks = new ArrayList<>();
      do {
        WSResponse wsResponse = userLovedTracksClient.getUserLovedTracks(user, page);
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          UserLovedTracksParser parser = new UserLovedTracksParserImpl(
              stringUtil.getInputStream());
          totalPages = parser.getTotalPages();
          lovedTracks.addAll(parser.getLovedTracks());
        }
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    setTotalOperations(artistNames.size());
   
    for (String artistName : artistNames) {
      try {
        WSResponse wsResponse = artistSimilarityClient.getArtistSimilarity(new Artist(artistName));
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          ArtistSimilarityParser asParser =
            new ArtistSimilarityParserImpl(stringUtil.getInputStream());
          artistRelationDao.createArtistRelations(asParser.getArtist(),
              asParser.getArtistRelations());
        }
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    setTotalOperations(tags.size());
   
    for (Tag tag : tags) {
      try {
        WSResponse wsResponse = tagTopArtistsClient.getTopArtists(tag);
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          TagTopArtistsParser parser =
              new TagTopArtistsParserImpl(stringUtil.getInputStream());
          topArtists.add(new TagTopArtists(tag.getName(), parser.getArtists()));
        }
      } catch (ApplicationException e) {
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

          if (previous != null && tooClose(scrobble, previous) &&
            scrobble.getTrack().getId() == previous.getTrack().getId()) {
            LOG.debug("Same track was scrobbled just recently, ignore.");
          } else {
            addScrobble(scrobble);
            WSResponse wsResponse = client.updateNowPlaying(message.getPayload());
            LOG.debug("Successful: " + wsResponse.wasCallSuccessful());
            LOG.debug("Response: " + wsResponse.getResponseBody());
          }
        } catch (ApplicationException e) {
          LOG.warn("Could not update now playing at last.fm.", e);
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.