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);
}
use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.
the class UserTopArtistsClientTest method validateParameters.
@Test
public void validateParameters() throws ApplicationException {
final String method = UserTopArtistsClient.METHOD;
final String lastFmUser = "arnathalon";
final Period period = Period.OVERALL;
new UserTopArtistsClient() {
@Override
protected WSResponse executeWSRequest(WebserviceInvocation wi, List<NameValuePair> params) throws ApplicationException {
Assert.assertEquals(Calltype.USER_GET_TOP_ARTISTS, wi.getCallType());
Assert.assertEquals(lastFmUser, wi.getUser().getLastFmUsername());
assertHasParameter(params, PARAM_METHOD, method);
assertHasParameter(params, PARAM_USER, lastFmUser);
assertHasParameter(params, PARAM_PERIOD, period.getDescription());
return null;
}
@Override
protected WebserviceHistoryService getHistoryService() {
return Mockito.mock(WebserviceHistoryService.class);
}
}.getUserTopArtists(new LastFmUser(lastFmUser), period);
}
use of com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation in project musiccabinet by hakko.
the class AbstractMusicBrainzClientTest method doesntLogFailedCall.
@Test
@SuppressWarnings("unchecked")
public void doesntLogFailedCall() throws Exception {
TestMusicBrainzClient client = getClient();
when(client.getHttpClient().execute(any(HttpUriRequest.class), any(ResponseHandler.class))).thenThrow(new IOException("Interrupted"));
WebserviceInvocation invocation = client.getInvocation();
try {
client.get();
} catch (ApplicationException e) {
verify(client.getWebserviceHistoryService(), never()).logWebserviceInvocation(invocation);
return;
}
Assert.fail();
}
Aggregations