AudioPlayerViewModel extends ViewModel implements MediaPlayer.OnCompletionListener { public void playInOrder(List<Clip> clips) { Queue<Clip> playlist = new LinkedList<>(clips); playNext(playlist); } AudioPlayerViewModel(MediaPlayerFactory mediaPlayerFactory, Scheduler scheduler); void play(Clip clip); void playInOrder(List<Clip> clips); void stop(); void pause(); LiveData<Boolean> isPlaying(@NonNull String clipID); LiveData<Integer> getPosition(String clipID); void setPosition(String clipID, Integer newPosition); void background(); @Override void onCompletion(MediaPlayer mediaPlayer); LiveData<Exception> getError(); void dismissError();  }
@Test public void playInOrder_whenThereIsAnErrorContinuesWithNextClip() throws Exception { doThrow(IOException.class).when(mediaPlayer).setDataSource("file: viewModel.playInOrder(asList( new Clip("clip1", "file: new Clip("clip2", "file: )); verify(mediaPlayer).setDataSource("file: verify(mediaPlayer, times(1)).start(); }