Package com.github.hakko.musiccabinet.util

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


    deleteLovedAndStarredTracks();
  }
 
  @Test
  public void createAndRetrievesUserLovedTracks() throws ApplicationException {
    List<Track> lovedTracks = new UserLovedTracksParserImpl(new ResourceUtil(
        LOVED_TRACKS_FILE).getInputStream()).getLovedTracks();
    dao.createLovedTracks(asList(new UserLovedTracks(USERNAME1, lovedTracks)));
    List<Track> dbLovedTracks = dao.getLovedTracks(USERNAME1);
   
    Collections.sort(lovedTracks);
View Full Code Here


    assertEquals(lovedTracks, dbLovedTracks);
  }

  @Test
  public void deletesUnlovedTracksIdentifiedInImport() throws ApplicationException {
    List<Track> lovedTracks = new UserLovedTracksParserImpl(new ResourceUtil(
        LOVED_TRACKS_FILE).getInputStream()).getLovedTracks();
    dao.createLovedTracks(asList(new UserLovedTracks(USERNAME1, lovedTracks)));

    lovedTracks.remove(0);
    dao.createLovedTracks(asList(new UserLovedTracks(USERNAME1, lovedTracks)));
View Full Code Here

    StatusLine statusLine = Mockito.mock(StatusLine.class);
    when(statusLine.getStatusCode()).thenReturn(200);
   
    HttpEntity httpEntity = Mockito.mock(HttpEntity.class);
    when(httpEntity.getContent()).thenReturn(new ResourceUtil(responseURI).getInputStream());
   
    HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
    when(httpResponse.getStatusLine()).thenReturn(statusLine);
    when(httpResponse.getEntity()).thenReturn(httpEntity);
   
View Full Code Here

    Assert.assertEquals(errorMessage, response.getErrorMessage());
  }

  @Test
  public void normalResponseValidatesCorrectly() throws ApplicationException, IOException {
    String normalResponse = new ResourceUtil(TOP_TRACKS_RESOURCE).getContent();
    WSResponse response = new WSResponse(normalResponse);
   
    assertTrue(response.wasCallSuccessful());
    assertEquals(normalResponse, response.getResponseBody());
  }
View Full Code Here

    assertEquals(normalResponse, response.getResponseBody());
  }

  @Test
  public void failedTrackResponseValidatesCorrectly() throws ApplicationException, IOException {
    String failedResponse = new ResourceUtil(FAILED_TRACK_RESOURCE).getContent();
    WSResponse response = new WSResponse(failedResponse);
   
    assertFalse(response.wasCallSuccessful());
    assertEquals(6, response.getErrorCode());
    assertEquals("Track not found", response.getErrorMessage());
View Full Code Here

    assertEquals("Track not found", response.getErrorMessage());
  }

  @Test
  public void failedKeyResponseValidatesCorrectly() throws ApplicationException, IOException {
    String failedResponse = new ResourceUtil(FAILED_KEY_RESOURCE).getContent();
    WSResponse response = new WSResponse(failedResponse);
   
    assertFalse(response.wasCallSuccessful());
    assertEquals(26, response.getErrorCode());
    assertEquals("Suspended API key", response.getErrorMessage());
View Full Code Here

   * Use an authentic response from last.fm, and assert that WSResponse
   * silently replaces illegal XML characters in it.
   */
  @Test
  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();
    } catch (ApplicationException e) {
     
    }
  }
View Full Code Here

   * Use an authentic response from last.fm, and assert that WSResponse
   * silently replaces illegal XML characters in it.
   */
  @Test
  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();
    } catch (ApplicationException e) {
     
    }
  }
View Full Code Here

  }
 
  @Test
  public void addCherSimilarTracksAndGetPlaylist() throws ApplicationException {
    TrackSimilarityParser tsParser = new TrackSimilarityParserImpl(
        new ResourceUtil(CHER_SIMILAR_TRACKS).getInputStream());
    trackRelationDao.createTrackRelations(
        tsParser.getTrack(), tsParser.getTrackRelations());
   
    List<File> files = new ArrayList<>();
    for (TrackRelation tr : tsParser.getTrackRelations()) {
View Full Code Here

    Assert.assertNotNull(ts);
  }
 
  private int prepareTestdataForArtist() throws ApplicationException {
    ArtistSimilarityParser asParser = new ArtistSimilarityParserImpl(
        new ResourceUtil(CHER_SIMILAR_ARTISTS).getInputStream());
    artistRelationDao.createArtistRelations(
        asParser.getArtist(), asParser.getArtistRelations());

    ArtistTopTracksParser attParser = new ArtistTopTracksParserImpl(
        new ResourceUtil(CHER_TOP_TRACKS).getInputStream());
    artistTopTracksDao.createTopTracks(
        attParser.getArtist(), attParser.getTopTracks());
   
    List<File> files = new ArrayList<>();
    for (Track topTrack : attParser.getTopTracks()) {
View Full Code Here

TOP

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

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.