Search in sources :

Example 1 with ArtistTopTagsDao

use of com.github.hakko.musiccabinet.dao.ArtistTopTagsDao 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);
}
Also used : TagUpdateClient(com.github.hakko.musiccabinet.ws.lastfm.TagUpdateClient) WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) ArtistTopTagsDao(com.github.hakko.musiccabinet.dao.ArtistTopTagsDao) Test(org.junit.Test)

Example 2 with ArtistTopTagsDao

use of com.github.hakko.musiccabinet.dao.ArtistTopTagsDao 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());
}
Also used : WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) ArtistTopTagsDao(com.github.hakko.musiccabinet.dao.ArtistTopTagsDao) Test(org.junit.Test)

Aggregations

ArtistTopTagsDao (com.github.hakko.musiccabinet.dao.ArtistTopTagsDao)2 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)2 Test (org.junit.Test)2 TagUpdateClient (com.github.hakko.musiccabinet.ws.lastfm.TagUpdateClient)1