Package com.github.hakko.musiccabinet.util

Examples of com.github.hakko.musiccabinet.util.StringUtil


  public void illegalControlCharactersAreChomped1() throws ApplicationException {
    String ctrlCharResponse = new ResourceUtil(CTRL_CHAR_RESPONSE_1).getContent();
    WSResponse response = new WSResponse(ctrlCharResponse);

    // supposed to work, as WSResponse chomps illegal control characters
    new ArtistInfoParserImpl(new StringUtil(response.getResponseBody()).getInputStream());
   
    try {
      // supposed to fail, as it hasn't passed WSResponse
      new ArtistInfoParserImpl(new ResourceUtil(CTRL_CHAR_RESPONSE_1).getInputStream());
      Assert.fail();
View Full Code Here


  public void illegalControlCharactersAreChomped2() throws ApplicationException {
    String ctrlCharResponse = new ResourceUtil(CTRL_CHAR_RESPONSE_2).getContent();
    WSResponse response = new WSResponse(ctrlCharResponse);

    // supposed to work, as WSResponse chomps illegal control characters
    new ArtistTopTracksParserImpl(new StringUtil(response.getResponseBody()).getInputStream());
   
    try {
      // supposed to fail, as it hasn't passed WSResponse
      new ArtistTopTracksParserImpl(new ResourceUtil(CTRL_CHAR_RESPONSE_2).getInputStream());
      Assert.fail();
View Full Code Here

        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

  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

      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());
        }
      } while (++page < totalPages);
      addFinishedOperation();
View Full Code Here

   
    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());
        }
      } catch (ApplicationException e) {
        LOG.warn("Fetching artist relations for " + artistName + " failed.", e);
View Full Code Here

   
    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) {
        LOG.warn("Fetching top artist for " + tag.getName() + " failed.", e);
      }
View Full Code Here

    for (String artistName : artistNames) {
      try {
        WSResponse wsResponse = artistInfoClient.getArtistInfo(
            new Artist(artistName), lastFmSettingsService.getLang());
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          ArtistInfoParser aiParser =
            new ArtistInfoParserImpl(stringUtil.getInputStream());
          if (aiParser.getArtistInfo() != null) {
            artistInfos.add(aiParser.getArtistInfo());
          } else {
            LOG.warn("Artist info response for " + artistName
                + " not parsed correctly. Response was "
View Full Code Here

    for (LastFmUser user : users) {
      for (Period period : Period.values()) {
        try {
          WSResponse wsResponse = userTopArtistsClient.getUserTopArtists(user, period);
          if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
            StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
            UserTopArtistsParser parser =
                new UserTopArtistsParserImpl(stringUtil.getInputStream());
            userTopArtists.add(new UserTopArtists(user, period, parser.getArtists()));
          }
        } catch (ApplicationException e) {
          LOG.warn("Fetching top artist for " + user.getLastFmUsername()
              + ", " + period.getDescription() + " failed.", e);
View Full Code Here

    List<Artist> missingArtists = artistDao.getMissingArtists();
    List<MBArtist> mbArtists = new ArrayList<>();
    mbids = missingArtists.size();
    for (Artist artist : artistDao.getMissingArtists()) {
      try {
        StringUtil response = new StringUtil(artistQueryClient.get(artist.getName()));
        ArtistQueryParser parser = new ArtistQueryParserImpl(response.getInputStream());
        if (parser.getArtist() != null) {
          mbArtists.add(parser.getArtist());
          if (mbArtists.size() > 100) {
            artistDao.createArtists(mbArtists);
            mbArtists.clear();
View Full Code Here

TOP

Related Classes of com.github.hakko.musiccabinet.util.StringUtil

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.