Search in sources :

Example 1 with ArtistSimilarityClient

use of com.github.hakko.musiccabinet.ws.lastfm.ArtistSimilarityClient in project musiccabinet by hakko.

the class ArtistRelationServiceTest method getArtistSimilarityClient.

@SuppressWarnings("unchecked")
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);
    // create a client that allows all calls and returns Cher artist relations
    ArtistSimilarityClient asClient = new ArtistSimilarityClient();
    asClient.setWebserviceHistoryService(historyService);
    asClient.setHttpClient(httpClient);
    asClient.setThrottleService(throttleService);
    return asClient;
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) ResourceUtil(com.github.hakko.musiccabinet.util.ResourceUtil) ResponseHandler(org.apache.http.client.ResponseHandler) ArtistSimilarityClient(com.github.hakko.musiccabinet.ws.lastfm.ArtistSimilarityClient) HttpClient(org.apache.http.client.HttpClient) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager)

Aggregations

ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)1 ArtistSimilarityClient (com.github.hakko.musiccabinet.ws.lastfm.ArtistSimilarityClient)1 HttpClient (org.apache.http.client.HttpClient)1 ResponseHandler (org.apache.http.client.ResponseHandler)1 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)1 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)1