use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.
the class ArtistQueryClientTest method getArtistQueryClient.
private ArtistQueryClient getArtistQueryClient() {
ArtistQueryClient artistQueryClient = new ArtistQueryClient();
HttpClient httpClient = Mockito.mock(HttpClient.class);
artistQueryClient.setHttpClient(httpClient);
WebserviceHistoryService webserviceHistoryService = Mockito.mock(WebserviceHistoryService.class);
artistQueryClient.setWebserviceHistoryService(webserviceHistoryService);
return artistQueryClient;
}
use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.
the class ReleaseGroupsClientTest method getReleaseGroupsClient.
private ReleaseGroupsClient getReleaseGroupsClient() {
ReleaseGroupsClient releaseGroupsClient = new ReleaseGroupsClient();
HttpClient httpClient = Mockito.mock(HttpClient.class);
releaseGroupsClient.setHttpClient(httpClient);
WebserviceHistoryService webserviceHistoryService = Mockito.mock(WebserviceHistoryService.class);
releaseGroupsClient.setWebserviceHistoryService(webserviceHistoryService);
return releaseGroupsClient;
}
use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.
the class TagUpdateServiceTest method updatesWithinThresholdsAreIgnored.
@Test
public void updatesWithinThresholdsAreIgnored() throws ApplicationException {
ArtistTopTagsDao artistTopTagsDao = mock(ArtistTopTagsDao.class);
tagUpdateService.setArtistTopTagsDao(artistTopTagsDao);
setClientResponse(responseOK);
TagUpdateClient tagUpdateClient = tagUpdateService.tagUpdateClient;
WebserviceHistoryService historyService = mock(WebserviceHistoryService.class);
tagUpdateService.setWebserviceHistoryService(historyService);
tagUpdateService.register(artist1Addition);
tagUpdateService.register(artist2Removal);
tagUpdateService.register(artist3Addition);
tagUpdateService.updateTags();
verify(tagUpdateClient, times(1)).updateTag(artist1Addition);
verify(tagUpdateClient, times(1)).updateTag(artist2Removal);
verify(tagUpdateClient, times(0)).updateTag(artist3Addition);
}
use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.
the class TagUpdateServiceTest method duplicateUpdatesAreRemoved.
@Test
public void duplicateUpdatesAreRemoved() throws ApplicationException {
tagUpdateService.failedUpdates.clear();
setClientResponse(responseFail);
ArtistTopTagsDao artistTopTagsDao = mock(ArtistTopTagsDao.class);
tagUpdateService.setArtistTopTagsDao(artistTopTagsDao);
WebserviceHistoryService historyService = mock(WebserviceHistoryService.class);
tagUpdateService.setWebserviceHistoryService(historyService);
tagUpdateService.register(artist1Addition);
tagUpdateService.register(artist1Addition);
tagUpdateService.register(artist1Addition);
tagUpdateService.updateTags();
// tag updates and web service blocking are instantaneous
verify(historyService, times(3)).blockWebserviceInvocation(artist1.getId(), ARTIST_GET_TOP_TAGS);
verify(artistTopTagsDao, times(3)).updateTopTag(artist1.getId(), artist1Addition.getTagName(), artist1Addition.getTagCount());
// dupes removed, one item updated and put on fail queue
assertEquals(1, tagUpdateService.failedUpdates.size());
}
use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.
the class AlbumInfoClientTest method validateParameters.
@Test
public void validateParameters() throws ApplicationException {
final String method = AlbumInfoClient.METHOD;
final String artistName = "The Beatles";
final String albumName = "Sergeant Pepper's Lonely Hearts Club Band";
new AlbumInfoClient() {
@Override
protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
Assert.assertEquals(Calltype.ALBUM_GET_INFO, wi.getCallType());
Assert.assertTrue(albumName.equals(wi.getAlbum().getName()));
assertHasParameter(params, PARAM_METHOD, method);
assertHasParameter(params, PARAM_ARTIST, artistName);
assertHasParameter(params, PARAM_ALBUM, albumName);
return null;
}
@Override
protected WebserviceHistoryService getHistoryService() {
return Mockito.mock(WebserviceHistoryService.class);
}
}.getAlbumInfo(new Album(artistName, albumName));
}
Aggregations