Search in sources :

Example 1 with Session

use of com.softartdev.lastfm.Session in project scroball by peterjosling.

the class LastfmClientTest method updateNowPlaying_returnsResultOnSuccess.

@Test
public void updateNowPlaying_returnsResultOnSuccess() {
    String track = "My Track";
    String artist = "Some Artist";
    when(lastfmApi.updateNowPlaying(any(), any())).thenReturn(scrobbleResult);
    when(scrobbleResult.isSuccessful()).thenReturn(true);
    client.updateNowPlaying(Track.builder().track(track).artist(artist).build(), callback);
    ScrobbleData expectedScrobbleData = new ScrobbleData();
    expectedScrobbleData.setTrack(track);
    expectedScrobbleData.setArtist(artist);
    verify(lastfmApi).updateNowPlaying(refEq(expectedScrobbleData, "timestamp"), refEq(session));
    verify(callback).handleMessage(argThat(message -> ((LastfmClient.Result) message.obj).isSuccessful()));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) Session(com.softartdev.lastfm.Session) ArgumentMatchers.refEq(org.mockito.ArgumentMatchers.refEq) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Truth.assertThat(com.google.common.truth.Truth.assertThat) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) ScrobbleData(com.softartdev.lastfm.scrobble.ScrobbleData) Mockito.verify(org.mockito.Mockito.verify) MockitoAnnotations(org.mockito.MockitoAnnotations) Handler(android.os.Handler) Result(com.softartdev.lastfm.Result) Build(android.os.Build) Caller(com.softartdev.lastfm.Caller) ScrobbleResult(com.softartdev.lastfm.scrobble.ScrobbleResult) Before(org.junit.Before) ScrobbleData(com.softartdev.lastfm.scrobble.ScrobbleData) Result(com.softartdev.lastfm.Result) ScrobbleResult(com.softartdev.lastfm.scrobble.ScrobbleResult) Test(org.junit.Test)

Aggregations

Build (android.os.Build)1 Handler (android.os.Handler)1 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Caller (com.softartdev.lastfm.Caller)1 Result (com.softartdev.lastfm.Result)1 Session (com.softartdev.lastfm.Session)1 ScrobbleData (com.softartdev.lastfm.scrobble.ScrobbleData)1 ScrobbleResult (com.softartdev.lastfm.scrobble.ScrobbleResult)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)1 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)1 ArgumentMatchers.refEq (org.mockito.ArgumentMatchers.refEq)1 Mock (org.mockito.Mock)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1 MockitoAnnotations (org.mockito.MockitoAnnotations)1