use of com.github.hakko.musiccabinet.ws.lastfm.ScrobbledTracksClient in project musiccabinet by hakko.
the class ScrobbledTracksServiceTest method getScrobbledTracksClient.
@SuppressWarnings("unchecked")
private ScrobbledTracksClient getScrobbledTracksClient() throws IOException {
// create a HistoryDao that allows all calls
WebserviceHistoryService historyService = mock(WebserviceHistoryService.class);
when(historyService.isWebserviceInvocationAllowed(Mockito.any(WebserviceInvocation.class))).thenReturn(true);
// 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();
stClient.setWebserviceHistoryService(historyService);
stClient.setHttpClient(httpClient);
// create a throttling service that allows calls at any rate
ThrottleService throttleService = mock(ThrottleService.class);
stClient.setThrottleService(throttleService);
return stClient;
}
use of com.github.hakko.musiccabinet.ws.lastfm.ScrobbledTracksClient in project musiccabinet by hakko.
the class ScrobbledTracksServiceTest method updatesScrobbledTracks.
@Test
public void updatesScrobbledTracks() throws IOException, ApplicationException {
ScrobbledTracksClient scrobbledTracksClient = getScrobbledTracksClient();
scrobbledTracksService.setScrobbledTracksClient(scrobbledTracksClient);
scrobbledTracksService.updateSearchIndex();
}
Aggregations