Search in sources :

Example 36 with WebserviceInvocation

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

the class JdbcWebserviceHistoryDaoTest method importUserRelatedDataNotPossibleTwice.

@Test
public void importUserRelatedDataNotPossibleTwice() {
    Calltype TOP_ARTISTS = Calltype.USER_GET_TOP_ARTISTS;
    LastFmUser user = new LastFmUser("arnathalon");
    WebserviceInvocation topArtists = new WebserviceInvocation(TOP_ARTISTS, user, OVERALL.getDays());
    deleteWebserviceInvocations();
    assertTrue(dao.isWebserviceInvocationAllowed(topArtists));
    dao.logWebserviceInvocation(topArtists);
    assertFalse(dao.isWebserviceInvocationAllowed(topArtists));
}
Also used : Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Example 37 with WebserviceInvocation

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

the class JdbcWebserviceHistoryDaoTest method differentGroupsDontInterfere.

@Test
public void differentGroupsDontInterfere() {
    Calltype GROUP_ARTISTS = Calltype.GROUP_WEEKLY_ARTIST_CHART;
    LastFmGroup group1 = new LastFmGroup("Brainwashed");
    LastFmGroup group2 = new LastFmGroup("Dark Ambient");
    WebserviceInvocation groupArtists1 = new WebserviceInvocation(GROUP_ARTISTS, group1);
    WebserviceInvocation groupArtists2 = new WebserviceInvocation(GROUP_ARTISTS, group2);
    deleteWebserviceInvocations();
    assertTrue(dao.isWebserviceInvocationAllowed(groupArtists1));
    assertTrue(dao.isWebserviceInvocationAllowed(groupArtists2));
    dao.logWebserviceInvocation(groupArtists2);
    assertTrue(dao.isWebserviceInvocationAllowed(groupArtists1));
    assertFalse(dao.isWebserviceInvocationAllowed(groupArtists2));
}
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)

Example 38 with WebserviceInvocation

use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation 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 39 with WebserviceInvocation

use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation 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)

Example 40 with WebserviceInvocation

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

the class JdbcWebserviceHistoryDaoTest method importTagRelatedDataNotPossibleTwice.

@Test
public void importTagRelatedDataNotPossibleTwice() {
    tagDao.createTags(Arrays.asList("disco"));
    Tag tag = tagDao.getTags().get(0);
    Calltype TOP_ARTISTS = Calltype.TAG_GET_TOP_ARTISTS;
    WebserviceInvocation topArtists = new WebserviceInvocation(TOP_ARTISTS, tag);
    deleteWebserviceInvocations();
    assertTrue(dao.isWebserviceInvocationAllowed(topArtists));
    dao.logWebserviceInvocation(topArtists);
    assertFalse(dao.isWebserviceInvocationAllowed(topArtists));
}
Also used : Calltype(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) 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