Search in sources :

Example 6 with WebserviceInvocation

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);
}
Also used : WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Example 7 with WebserviceInvocation

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;
}
Also used : WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) HttpClient(org.apache.http.client.HttpClient) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)

Example 8 with WebserviceInvocation

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));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Example 9 with WebserviceInvocation

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));
}
Also used : Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Example 10 with WebserviceInvocation

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));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) File(com.github.hakko.musiccabinet.domain.model.library.File) Test(org.junit.Test)

Aggregations

WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)53 Test (org.junit.Test)36 NameValuePair (org.apache.http.NameValuePair)26 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)19 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)19 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)16 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)13 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)11 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)7 Track (com.github.hakko.musiccabinet.domain.model.music.Track)4 ArrayList (java.util.ArrayList)4 LastFmGroup (com.github.hakko.musiccabinet.domain.model.library.LastFmGroup)3 Tag (com.github.hakko.musiccabinet.domain.model.music.Tag)3 HttpClient (org.apache.http.client.HttpClient)2 LastFmDao (com.github.hakko.musiccabinet.dao.LastFmDao)1 File (com.github.hakko.musiccabinet.domain.model.library.File)1 Period (com.github.hakko.musiccabinet.domain.model.library.Period)1 Album (com.github.hakko.musiccabinet.domain.model.music.Album)1 ThrottleService (com.github.hakko.musiccabinet.service.lastfm.ThrottleService)1 IOException (java.io.IOException)1