Search in sources :

Example 11 with WebserviceHistoryService

use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.

the class ArtistSimilarityClientTest method validateParameters.

@Test
public void validateParameters() throws ApplicationException {
    final String method = ArtistSimilarityClient.METHOD;
    final String artistName = "madonna";
    new ArtistSimilarityClient() {

        @Override
        protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
            Assert.assertEquals(Calltype.ARTIST_GET_SIMILAR, wi.getCallType());
            Assert.assertTrue(artistName.equals(wi.getArtist().getName()));
            assertHasParameter(params, PARAM_METHOD, method);
            assertHasParameter(params, PARAM_ARTIST, artistName);
            return null;
        }

        @Override
        protected WebserviceHistoryService getHistoryService() {
            return Mockito.mock(WebserviceHistoryService.class);
        }
    }.getArtistSimilarity(new Artist(artistName));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) NameValuePair(org.apache.http.NameValuePair) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Example 12 with WebserviceHistoryService

use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.

the class ArtistTopTracksClientTest method validateParameters.

@Test
public void validateParameters() throws ApplicationException {
    final String method = ArtistTopTracksClient.METHOD;
    final String artistName = "madonna";
    new ArtistTopTracksClient() {

        @Override
        protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
            Assert.assertEquals(Calltype.ARTIST_GET_TOP_TRACKS, wi.getCallType());
            Assert.assertTrue(artistName.equals(wi.getArtist().getName()));
            assertHasParameter(params, PARAM_METHOD, method);
            assertHasParameter(params, PARAM_ARTIST, artistName);
            return null;
        }

        @Override
        protected WebserviceHistoryService getHistoryService() {
            return Mockito.mock(WebserviceHistoryService.class);
        }
    }.getTopTracks(new Artist(artistName));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) NameValuePair(org.apache.http.NameValuePair) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Example 13 with WebserviceHistoryService

use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.

the class TagTopArtistsClientTest method validateParameters.

@Test
public void validateParameters() throws ApplicationException {
    final String method = TagTopArtistsClient.METHOD;
    final Tag tag = new Tag(0, "sludge");
    new TagTopArtistsClient() {

        @Override
        protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
            Assert.assertEquals(Calltype.TAG_GET_TOP_ARTISTS, wi.getCallType());
            Assert.assertEquals(tag, wi.getTag());
            assertHasParameter(params, PARAM_METHOD, method);
            assertHasParameter(params, PARAM_TAG, tag.getName());
            return null;
        }

        @Override
        protected WebserviceHistoryService getHistoryService() {
            return Mockito.mock(WebserviceHistoryService.class);
        }
    }.getTopArtists(tag);
}
Also used : NameValuePair(org.apache.http.NameValuePair) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag) Test(org.junit.Test)

Example 14 with WebserviceHistoryService

use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.

the class TrackSimilarityClientTest method validateParameters.

@Test
public void validateParameters() throws ApplicationException {
    final String method = TrackSimilarityClient.METHOD;
    final String artistName = "madonna";
    final String trackName = "ray of light";
    new TrackSimilarityClient() {

        @Override
        protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
            assertEquals(Calltype.TRACK_GET_SIMILAR, wi.getCallType());
            assertTrue(trackName.equals(wi.getTrack().getName()));
            assertTrue(artistName.equals(wi.getTrack().getArtist().getName()));
            assertHasParameter(params, PARAM_METHOD, method);
            assertHasParameter(params, PARAM_ARTIST, artistName);
            assertHasParameter(params, PARAM_TRACK, trackName);
            return null;
        }

        @Override
        protected WebserviceHistoryService getHistoryService() {
            return Mockito.mock(WebserviceHistoryService.class);
        }
    }.getTrackSimilarity(new Track(new Artist(artistName), trackName));
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) NameValuePair(org.apache.http.NameValuePair) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Test(org.junit.Test)

Example 15 with WebserviceHistoryService

use of com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService in project musiccabinet by hakko.

the class UserLovedTracksClientTest method validateParameters.

@Test
public void validateParameters() throws ApplicationException {
    final String method = UserLovedTracksClient.METHOD;
    final String limit = UserLovedTracksClient.LIMIT;
    final LastFmUser lastFmUser = new LastFmUser("rj");
    final short page = 4;
    new UserLovedTracksClient() {

        @Override
        protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
            Assert.assertEquals(Calltype.USER_GET_LOVED_TRACKS, wi.getCallType());
            Assert.assertEquals(lastFmUser, wi.getUser());
            assertHasParameter(params, PARAM_METHOD, method);
            assertHasParameter(params, PARAM_LIMIT, limit);
            assertHasParameter(params, PARAM_USER, lastFmUser.getLastFmUsername());
            assertHasParameter(params, PARAM_PAGE, Short.toString(page));
            return null;
        }

        @Override
        protected WebserviceHistoryService getHistoryService() {
            return Mockito.mock(WebserviceHistoryService.class);
        }
    }.getUserLovedTracks(lastFmUser, page);
}
Also used : NameValuePair(org.apache.http.NameValuePair) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) WebserviceHistoryService(com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation) Test(org.junit.Test)

Aggregations

WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)16 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)12 Test (org.junit.Test)12 NameValuePair (org.apache.http.NameValuePair)11 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)10 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)5 HttpClient (org.apache.http.client.HttpClient)4 ArtistTopTagsDao (com.github.hakko.musiccabinet.dao.ArtistTopTagsDao)2 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)2 LastFmGroup (com.github.hakko.musiccabinet.domain.model.library.LastFmGroup)1 Period (com.github.hakko.musiccabinet.domain.model.library.Period)1 Album (com.github.hakko.musiccabinet.domain.model.music.Album)1 Tag (com.github.hakko.musiccabinet.domain.model.music.Tag)1 Track (com.github.hakko.musiccabinet.domain.model.music.Track)1 ThrottleService (com.github.hakko.musiccabinet.service.lastfm.ThrottleService)1 TagUpdateClient (com.github.hakko.musiccabinet.ws.lastfm.TagUpdateClient)1 ArrayList (java.util.ArrayList)1 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)1 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)1