@Test
public void testPauseRecording()throws InterruptedException,IllegalAccessException{

    PauseResumeAudioRecorder pauseResumeAudioRecorder=new PauseResumeAudioRecorder();
    pauseResumeAudioRecorder.setAudioFile(Environment.getExternalStorageDirectory() + "/recording.wav");
    pauseResumeAudioRecorder.setChannel(AudioFormat.CHANNEL_IN_STEREO);
    pauseResumeAudioRecorder.setSampleRate(44100);
    pauseResumeAudioRecorder.setAudioEncoding(AudioFormat.ENCODING_PCM_8BIT);
    pauseResumeAudioRecorder.startRecording();
    onTimeCompletedTimerField.set(pauseResumeAudioRecorder, mockTimer);
    Thread.sleep(100);
    pauseResumeAudioRecorder.pauseRecording();
    Thread.sleep(200);
    long remainingTimeMillis=((long) remainingMaxTimeInMillisField.get(pauseResumeAudioRecorder));
    Assert.assertTrue("wrong time:"+remainingTimeMillis,(remainingTimeMillis<=(PcmWavConverter.MAX_TIME_WAV_FILE_MILLIS-100)) &&remainingTimeMillis>(PcmWavConverter.MAX_TIME_WAV_FILE_MILLIS-5000));
    Mockito.verify(mockTimer,Mockito.times(1)).cancel();
    Assert.assertEquals("Correct state not set", PauseResumeAudioRecorder.PAUSED_STATE, pauseResumeAudioRecorder.getCurrentState());
    final File pcmFile=new File(Environment.getExternalStorageDirectory() + "/recording.pcm");
    pcmFile.delete();
    Thread.sleep(100);//Give it time to recreate the file if it is running incorrectly.
    Assert.assertFalse("Thread is not paused", pcmFile.exists());
}