AudioPlayerManager { public void play(String fileName, boolean isAsset) throws AudioFileException { if(fileName == null || fileName.isEmpty()) { throw new AudioFileException(MainApplication.getContextFromMainApp().getString(R.string.could_not_play_audio_message)); } prepareMediaPlayer(fileName, isAsset); mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { stop(); } }); mediaPlayer.start(); } AudioPlayerManager(MediaPlayer mediaPlayer); void stop(); void play(String fileName, boolean isAsset); int getCurrentPosition(); int getMaxDuration(); boolean isPlaying();  }
@Test public void shouldPrepareMediaPlayer() throws AudioFileException, IOException { audioPlayerManager.play(ANY_FILE, IS_NOT_ASSET); verify(mediaPlayer).prepare(); }
@Test public void shouldStartMediaPlayer() throws AudioFileException { audioPlayerManager.play(ANY_FILE, IS_NOT_ASSET); verify(mediaPlayer).start(); }
@Test (expected = AudioFileException.class) public void shouldThrowExceptionWhenNoAudioFileIsFound() throws AudioFileException, IOException { audioPlayerManager.play("", false); }