Search in sources :

Example 31 with WebserviceInvocation

use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.

the class JdbcWebserviceHistoryDaoTest method importTrackSimilaritiesIsPossibleForCovers.

@Test
public void importTrackSimilaritiesIsPossibleForCovers() {
    Calltype SIMILAR = Calltype.TRACK_GET_SIMILAR;
    Track track1 = new Track("Daniel Johnston", "True Love Will Find You In The End");
    Track track2 = new Track("Headless Heroes", "True Love Will Find You In The End");
    WebserviceInvocation similarTrack1 = new WebserviceInvocation(SIMILAR, track1);
    WebserviceInvocation similarTrack2 = new WebserviceInvocation(SIMILAR, track2);
    deleteWebserviceInvocations();
    assertTrue(dao.isWebserviceInvocationAllowed(similarTrack1));
    assertTrue(dao.isWebserviceInvocationAllowed(similarTrack2));
    dao.logWebserviceInvocation(similarTrack1);
    assertFalse(dao.isWebserviceInvocationAllowed(similarTrack1));
    assertTrue(dao.isWebserviceInvocationAllowed(similarTrack2));
    dao.logWebserviceInvocation(similarTrack2);
    assertFalse(dao.isWebserviceInvocationAllowed(similarTrack1));
    assertFalse(dao.isWebserviceInvocationAllowed(similarTrack2));
}
Also used : Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Test(org.junit.Test)

Example 32 with WebserviceInvocation

use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.

the class JdbcWebserviceHistoryDaoTest method webserviceHistoryIsCaseInsensitive.

@Test
public void webserviceHistoryIsCaseInsensitive() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Artist artist1 = new Artist("Håll Det Äkta");
    Artist artist2 = new Artist("HÅLL DET ÄKTA");
    WebserviceInvocation topArtist1 = new WebserviceInvocation(TOP, artist1);
    WebserviceInvocation topArtist2 = new WebserviceInvocation(TOP, artist2);
    deleteWebserviceInvocations();
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist1));
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist2));
    dao.logWebserviceInvocation(topArtist1);
    assertFalse(dao.isWebserviceInvocationAllowed(topArtist1));
    assertFalse(dao.isWebserviceInvocationAllowed(topArtist2));
}
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) Test(org.junit.Test)

Example 33 with WebserviceInvocation

use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.

the class JdbcWebserviceHistoryDaoTest method importArtistSimilaritiesAndTopTracksWorkIndependently.

@Test
public void importArtistSimilaritiesAndTopTracksWorkIndependently() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Calltype SIMILAR = Calltype.ARTIST_GET_SIMILAR;
    Artist artist1 = new Artist("Björk");
    Artist artist2 = new Artist("Björn Olsson");
    WebserviceInvocation topArtist1 = new WebserviceInvocation(TOP, artist1);
    WebserviceInvocation topArtist2 = new WebserviceInvocation(TOP, artist2);
    WebserviceInvocation similarArtist1 = new WebserviceInvocation(SIMILAR, artist1);
    WebserviceInvocation similarArtist2 = new WebserviceInvocation(SIMILAR, artist2);
    deleteWebserviceInvocations();
    // everything's allowed
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist1));
    assertTrue(dao.isWebserviceInvocationAllowed(similarArtist1));
    // invoke SIMILAR for artist1, TOP is still allowed
    dao.logWebserviceInvocation(similarArtist1);
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist1));
    assertFalse(dao.isWebserviceInvocationAllowed(similarArtist1));
    // invoke TOP for artist2, SIMILAR is still allowed
    dao.logWebserviceInvocation(topArtist2);
    assertFalse(dao.isWebserviceInvocationAllowed(topArtist2));
    assertTrue(dao.isWebserviceInvocationAllowed(similarArtist2));
}
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) Test(org.junit.Test)

Example 34 with WebserviceInvocation

use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.

the class JdbcWebserviceHistoryDaoTest method blockLogsInvocationTimeInAnInfiniteFuture.

@Test
public void blockLogsInvocationTimeInAnInfiniteFuture() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Artist artist = new Artist("Björn Olsson");
    int artistId = musicDao.getArtistId(artist);
    WebserviceInvocation wi = new WebserviceInvocation(TOP, artist);
    assertTrue(dao.isWebserviceInvocationAllowed(wi));
    dao.blockWebserviceInvocation(artistId, TOP);
    assertFalse(dao.isWebserviceInvocationAllowed(wi));
    dao.getJdbcTemplate().queryForObject("select 1 from library.webservice_history" + " where artist_id = ? and calltype_id = ? and invocation_time = 'infinity'", Integer.class, artistId, TOP.getDatabaseId());
}
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) Test(org.junit.Test)

Example 35 with WebserviceInvocation

use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.

the class JdbcWebserviceHistoryDaoTest method importGroupRelatedDataNotPossibleTwice.

@Test
public void importGroupRelatedDataNotPossibleTwice() {
    Calltype GROUP_ARTISTS = Calltype.GROUP_WEEKLY_ARTIST_CHART;
    LastFmGroup group = new LastFmGroup("Brainwashed");
    WebserviceInvocation groupArtists = new WebserviceInvocation(GROUP_ARTISTS, group);
    deleteWebserviceInvocations();
    assertTrue(dao.isWebserviceInvocationAllowed(groupArtists));
    dao.logWebserviceInvocation(groupArtists);
    assertFalse(dao.isWebserviceInvocationAllowed(groupArtists));
}
Also used : LastFmGroup(com.github.hakko.musiccabinet.domain.model.library.LastFmGroup) Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) 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