Search in sources :

Example 41 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist 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 42 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist 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 43 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist 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 44 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class JdbcWebserviceHistoryDaoTest method importArtistTopTracksNotPossibleTwice.

@Test
public void importArtistTopTracksNotPossibleTwice() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Artist artist1 = new Artist("Esben And The Witch");
    Artist artist2 = new Artist("Espers");
    Artist artist3 = new Artist("Essie Jain");
    WebserviceInvocation topArtist1 = new WebserviceInvocation(TOP, artist1);
    WebserviceInvocation topArtist2 = new WebserviceInvocation(TOP, artist2);
    WebserviceInvocation topArtist3 = new WebserviceInvocation(TOP, artist3);
    deleteWebserviceInvocations();
    // possible for all of them
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist1));
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist2));
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist3));
    // invoke artist1
    dao.logWebserviceInvocation(topArtist1);
    // now possible for all of them but artist1
    assertFalse(dao.isWebserviceInvocationAllowed(topArtist1));
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist2));
    assertTrue(dao.isWebserviceInvocationAllowed(topArtist3));
    // invoke artist2 & artist3
    dao.logWebserviceInvocation(topArtist2);
    dao.logWebserviceInvocation(topArtist3);
    // now none of them can be invoked
    assertFalse(dao.isWebserviceInvocationAllowed(topArtist1));
    assertFalse(dao.isWebserviceInvocationAllowed(topArtist2));
    assertFalse(dao.isWebserviceInvocationAllowed(topArtist3));
}
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 45 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class JdbcWebserviceHistoryDaoTest method quarantineLogsInvocationTimeInTheFuture.

@Test
public void quarantineLogsInvocationTimeInTheFuture() {
    Calltype TOP = Calltype.ARTIST_GET_TOP_TRACKS;
    Artist artist = new Artist("The Notorious B.I.G feat. G. Dep & Missy Elliott");
    WebserviceInvocation wi = new WebserviceInvocation(TOP, artist);
    assertTrue(dao.isWebserviceInvocationAllowed(wi));
    dao.quarantineWebserviceInvocation(wi);
    assertFalse(dao.isWebserviceInvocationAllowed(wi));
    Date date = dao.getJdbcTemplate().queryForObject("select invocation_time from library.webservice_history hist" + " inner join music.artist a on hist.artist_id = a.id" + " where a.artist_name = upper(?)", Date.class, artist.getName());
    Assert.assertTrue(date.after(new Date()));
}
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) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)66 Test (org.junit.Test)33 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)19 ArrayList (java.util.ArrayList)13 Album (com.github.hakko.musiccabinet.domain.model.music.Album)11 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)11 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)10 Track (com.github.hakko.musiccabinet.domain.model.music.Track)9 File (com.github.hakko.musiccabinet.domain.model.library.File)8 NameValuePair (org.apache.http.NameValuePair)8 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)7 Before (org.junit.Before)6 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)5 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)5 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)5 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)5 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)4 Tag (com.github.hakko.musiccabinet.domain.model.music.Tag)4 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 ResultSet (java.sql.ResultSet)4