use of com.github.hakko.musiccabinet.ws.lastfm.ArtistTopTagsClient in project musiccabinet by hakko.
the class ArtistTopTagsServiceTest method getArtistTopTagsClient.
@SuppressWarnings("unchecked")
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);
// create a client based on mocked HTTP client
ArtistTopTagsClient attClient = new ArtistTopTagsClient();
attClient.setWebserviceHistoryService(historyService);
attClient.setHttpClient(httpClient);
attClient.setThrottleService(throttleService);
return attClient;
}
Aggregations