use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.
the class AbstractMusicBrainzClientTest method logsSuccessfulCall.
@Test
public void logsSuccessfulCall() throws ApplicationException {
TestMusicBrainzClient client = getClient();
WebserviceInvocation invocation = client.getInvocation();
verify(client.getWebserviceHistoryService(), never()).logWebserviceInvocation(invocation);
client.get();
verify(client.getWebserviceHistoryService()).logWebserviceInvocation(invocation);
}
use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.
the class AbstractMusicBrainzClientTest method getClient.
private TestMusicBrainzClient getClient() {
WebserviceInvocation invocation = Mockito.mock(WebserviceInvocation.class);
TestMusicBrainzClient client = new TestMusicBrainzClient(invocation);
HttpClient httpClient = Mockito.mock(HttpClient.class);
client.setHttpClient(httpClient);
WebserviceHistoryService webserviceHistoryService = Mockito.mock(WebserviceHistoryService.class);
client.setWebserviceHistoryService(webserviceHistoryService);
return client;
}
use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.
the class ArtistTopTagsServiceTest method artistTopTagsUpdateUpdatesAllArtists.
@Test
public void artistTopTagsUpdateUpdatesAllArtists() throws ApplicationException, IOException {
clearLibraryAndAddCherTrack();
WebserviceInvocation wi = new WebserviceInvocation(ARTIST_GET_TOP_TAGS, new Artist(artistName));
Assert.assertTrue(webserviceHistoryService.isWebserviceInvocationAllowed(wi));
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_TOP_TAGS);
Assert.assertNotNull(artistNames);
Assert.assertEquals(1, artistNames.size());
Assert.assertTrue(artistNames.contains(artistName));
ArtistTopTagsService artistTopTagsService = new ArtistTopTagsService();
artistTopTagsService.setArtistTopTagsClient(getArtistTopTagsClient(webserviceHistoryService));
artistTopTagsService.setArtistTopTagsDao(artistTopTagsDao);
artistTopTagsService.setWebserviceHistoryService(webserviceHistoryService);
artistTopTagsService.updateSearchIndex();
Assert.assertFalse(webserviceHistoryService.isWebserviceInvocationAllowed(wi));
}
use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method importPageFromPersonLibraryNotPossibleTwice.
@Test
public void importPageFromPersonLibraryNotPossibleTwice() {
Calltype LIB = Calltype.GET_SCROBBLED_TRACKS;
short page3 = 3;
short page4 = 4;
WebserviceInvocation libPage3 = new WebserviceInvocation(LIB, page3);
WebserviceInvocation libPage4 = new WebserviceInvocation(LIB, page4);
deleteWebserviceInvocations();
assertTrue(dao.isWebserviceInvocationAllowed(libPage3));
assertTrue(dao.isWebserviceInvocationAllowed(libPage4));
dao.logWebserviceInvocation(libPage4);
assertTrue(dao.isWebserviceInvocationAllowed(libPage3));
assertFalse(dao.isWebserviceInvocationAllowed(libPage4));
dao.logWebserviceInvocation(libPage3);
assertFalse(dao.isWebserviceInvocationAllowed(libPage3));
assertFalse(dao.isWebserviceInvocationAllowed(libPage4));
}
use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.
the class JdbcWebserviceHistoryDaoTest method identifiesArtistsWithoutInvocations.
@Test
public void identifiesArtistsWithoutInvocations() {
deleteLibraryTracks();
deleteWebserviceInvocations();
File file = UnittestLibraryUtil.getFile("Madonna", null, "Jump");
UnittestLibraryUtil.submitFile(additionDao, file);
final Calltype INFO = ARTIST_GET_INFO, TOP_TRACKS = ARTIST_GET_TOP_TRACKS;
final String MADONNA = file.getMetadata().getArtist();
List<String> artistInfo, artistTopTracks;
artistInfo = dao.getArtistNamesWithNoInvocations(INFO);
artistTopTracks = dao.getArtistNamesWithNoInvocations(TOP_TRACKS);
Assert.assertNotNull(artistInfo);
Assert.assertNotNull(artistTopTracks);
Assert.assertTrue(artistInfo.contains(MADONNA));
Assert.assertTrue(artistTopTracks.contains(MADONNA));
dao.logWebserviceInvocation(new WebserviceInvocation(INFO, new Artist(MADONNA)));
artistInfo = dao.getArtistNamesWithNoInvocations(INFO);
artistTopTracks = dao.getArtistNamesWithNoInvocations(TOP_TRACKS);
Assert.assertFalse(artistInfo.contains(MADONNA));
Assert.assertTrue(artistTopTracks.contains(MADONNA));
dao.logWebserviceInvocation(new WebserviceInvocation(TOP_TRACKS, new Artist(MADONNA)));
artistInfo = dao.getArtistNamesWithNoInvocations(INFO);
artistTopTracks = dao.getArtistNamesWithNoInvocations(TOP_TRACKS);
Assert.assertFalse(artistInfo.contains(MADONNA));
Assert.assertFalse(artistTopTracks.contains(MADONNA));
}
Aggregations