Package com.github.hakko.musiccabinet.util

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


  private ArtistTopTagsClient getArtistTopTagsClient(WebserviceHistoryService historyService) throws IOException {
    // create a HTTP client that always returns Cher top tracks
    HttpClient httpClient = mock(HttpClient.class);
    ClientConnectionManager connectionManager = mock(ClientConnectionManager.class);
    when(httpClient.getConnectionManager()).thenReturn(connectionManager);
    String httpResponse = new ResourceUtil(CHER_TOP_TAGS).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);

    // create a throttling service that allows calls at any rate
    ThrottleService throttleService = mock(ThrottleService.class);
View Full Code Here


    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);
View Full Code Here

    testWSClient.close();
   
    Assert.assertTrue(wsResponse.wasCallAllowed());
    Assert.assertTrue(wsResponse.wasCallSuccessful());
    Assert.assertEquals(wsResponse.getResponseBody(),
        new ResourceUtil(SIMILAR_TRACKS_RESOURCE).getContent());
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private TestWSGetClient getTestWSClient(
      boolean allowCalls, String responseURI) throws IOException {
    TestWSGetClient testWSClient = getTestWSClient(allowCalls);
    HttpClient httpClient = testWSClient.getHttpClient();
    String httpResponse = new ResourceUtil(responseURI).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);
    return testWSClient;
  }
View Full Code Here

  @Before
  public void loadFunctionDependencyAndTestdata() throws ApplicationException {
    PostgreSQLUtil.loadFunction(dao, UPDATE_ARTISTTOPTAG);

    ArtistTopTagsParser cherParser = new ArtistTopTagsParserImpl(
        new ResourceUtil(CHER_TOP_TAGS).getInputStream());
    ArtistTopTagsParser rihannaParser = new ArtistTopTagsParserImpl(
        new ResourceUtil(RIHANNA_TOP_TAGS).getInputStream());
    cherArtist = cherParser.getArtist();
    cherTopTags = cherParser.getTopTags();
    rihannaArtist = rihannaParser.getArtist();
    rihannaTopTags = rihannaParser.getTopTags();
View Full Code Here

  private ArtistSimilarityClient getArtistSimilarityClient(WebserviceHistoryService historyService) throws IOException {
    // create a HTTP client that always returns Cher artist relations
    HttpClient httpClient = mock(HttpClient.class);
    ClientConnectionManager connectionManager = mock(ClientConnectionManager.class);
    when(httpClient.getConnectionManager()).thenReturn(connectionManager);
    String httpResponse = new ResourceUtil(CHER_ARTIST_RELATIONS).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);
   
    // create a throttling service that allows calls at any rate
    ThrottleService throttleService = mock(ThrottleService.class);
View Full Code Here

    // create a HTTP client that always returns sampled scrobbled tracks from last.fm
    HttpClient httpClient = mock(HttpClient.class);
    ClientConnectionManager connectionManager = mock(ClientConnectionManager.class);
    when(httpClient.getConnectionManager()).thenReturn(connectionManager);
    String httpResponse = new ResourceUtil(SCROBBLED_TRACKS).getContent();
    when(httpClient.execute(Mockito.any(HttpUriRequest.class),
        Mockito.any(ResponseHandler.class))).thenReturn(httpResponse);

    // create a client out of the components above
    ScrobbledTracksClient stClient = new ScrobbledTracksClient();
View Full Code Here

    }
  }

  private String getPostgresPassword() {
    Properties props = new Properties();
    try (ResourceUtil resourceUtil = new ResourceUtil("local.jdbc.properties")) {
      props.load(resourceUtil.getInputStream());
    } catch (IOException e) {
      Assert.fail("IOException encountered while reading password!");
    }
    String password = props.getProperty("musiccabinet.jdbc.password");
    Assert.assertNotNull(password);
View Full Code Here

 
  private ArtistQueryClient getArtistQueryClient() throws ApplicationException {
    ArtistQueryClient client = Mockito.mock(ArtistQueryClient.class);
   
    Mockito.when(client.get(artistName)).thenReturn(
        new ResourceUtil("musicbrainz/xml/artistQuery.xml").getContent());
     
    return client;
  }
View Full Code Here

  private ReleaseClient getReleaseClient() throws ApplicationException {
    ReleaseClient client = Mockito.mock(ReleaseClient.class);
   
    Mockito.when(client.get(artistName, mbid, 0)).thenReturn(
        new ResourceUtil("musicbrainz/xml/release-col.xml").getContent());
   
    return client;
  }
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.