Search in sources :

Example 41 with WebserviceInvocation

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

the class ArtistTopTagsClient method getTopTags.

public WSResponse getTopTags(Artist artist) throws ApplicationException {
    WebserviceInvocation webserviceInvocation = new WebserviceInvocation(ARTIST_GET_TOP_TAGS, artist);
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_ARTIST, artist.getName()));
    return executeWSRequest(webserviceInvocation, params);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)

Example 42 with WebserviceInvocation

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

the class ArtistTopTracksClient method getTopTracks.

public WSResponse getTopTracks(Artist artist) throws ApplicationException {
    WebserviceInvocation webserviceInvocation = new WebserviceInvocation(ARTIST_GET_TOP_TRACKS, artist);
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_ARTIST, artist.getName()));
    return executeWSRequest(webserviceInvocation, params);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)

Example 43 with WebserviceInvocation

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

the class TagTopArtistsClient method getTopArtists.

public WSResponse getTopArtists(Tag tag) throws ApplicationException {
    WebserviceInvocation webserviceInvocation = new WebserviceInvocation(TAG_GET_TOP_ARTISTS, tag);
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_TAG, tag.getName()));
    return executeWSRequest(webserviceInvocation, params);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)

Example 44 with WebserviceInvocation

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

Example 45 with WebserviceInvocation

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

the class UserRecommendedArtistsClientTest method validateParameters.

@Test
public void validateParameters() throws ApplicationException {
    final String method = UserRecommendedArtistsClient.METHOD;
    final String lastFmUser = "arnathalon";
    final String sessionKey = "sessionkey";
    UserRecommendedArtistsClient client = new UserRecommendedArtistsClient() {

        @Override
        protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
            Assert.assertEquals(Calltype.USER_GET_RECOMMENDED_ARTISTS, wi.getCallType());
            assertHasParameter(params, PARAM_METHOD, method);
            assertHasParameter(params, PARAM_LIMIT, "100");
            assertHasParameter(params, PARAM_SK, sessionKey);
            return null;
        }
    };
    client.setWebserviceHistoryService(Mockito.mock(WebserviceHistoryService.class));
    LastFmDao dao = Mockito.mock(LastFmDao.class);
    Mockito.when(dao.getLastFmUser(Mockito.anyString())).thenReturn(new LastFmUser(lastFmUser, sessionKey));
    client.setLastFmDao(dao);
    client.getUserRecommendedArtists(lastFmUser);
}
Also used : 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) List(java.util.List) LastFmDao(com.github.hakko.musiccabinet.dao.LastFmDao) 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