@Test public void loveTrack_queuesParallelLikeRequests() { List<Handler.Callback> callbacks = new ArrayList<>(); doAnswer(invocation -> { callbacks.add(invocation.getArgument(1)); return null; }).when(lastfmClient).loveTrack(any(), any()); trackLover.loveTrack(track1); trackLover.loveTrack(track2); assertThat(callbacks.size()).isEqualTo(1); verify(lastfmClient).loveTrack(eq(track1), any()); verifyNoMoreInteractions(lastfmClient); message.obj = LastfmClient.Result.success(); callbacks.get(0).handleMessage(message); verify(lastfmClient).loveTrack(eq(track2), any()); }
public synchronized void loveTrack(Track track) { if (scroballDB.isLoved(track)) { return; } LovedTracksEntry entry = scroballDB.writeLove(track, 0); pending.add(entry); lovePending(); eventBus.post(TrackLovedEvent.create()); }
TrackLover { public synchronized void loveTrack(Track track) { if (scroballDB.isLoved(track)) { return; } LovedTracksEntry entry = scroballDB.writeLove(track, 0); pending.add(entry); lovePending(); eventBus.post(TrackLovedEvent.create()); } }
TrackLover { public synchronized void loveTrack(Track track) { if (scroballDB.isLoved(track)) { return; } LovedTracksEntry entry = scroballDB.writeLove(track, 0); pending.add(entry); lovePending(); eventBus.post(TrackLovedEvent.create()); } TrackLover(
      LastfmClient lastfmClient, ScroballDB scroballDB, ConnectivityManager connectivityManager); }
TrackLover { public synchronized void loveTrack(Track track) { if (scroballDB.isLoved(track)) { return; } LovedTracksEntry entry = scroballDB.writeLove(track, 0); pending.add(entry); lovePending(); eventBus.post(TrackLovedEvent.create()); } TrackLover(
      LastfmClient lastfmClient, ScroballDB scroballDB, ConnectivityManager connectivityManager); synchronized void loveTrack(Track track); synchronized void lovePending(); }
TrackLover { public synchronized void loveTrack(Track track) { if (scroballDB.isLoved(track)) { return; } LovedTracksEntry entry = scroballDB.writeLove(track, 0); pending.add(entry); lovePending(); eventBus.post(TrackLovedEvent.create()); } TrackLover(
      LastfmClient lastfmClient, ScroballDB scroballDB, ConnectivityManager connectivityManager); synchronized void loveTrack(Track track); synchronized void lovePending();  }