AudioCaptureHelper extends CaptureHelper { public void saveAudio(BaseModel baseModel, InputStream inputStream) throws JSONException, IOException { File file = new File(getDir(), baseModel.getRecordedAudio()); if (!file.exists() && !baseModel.getRecordedAudio().equals("")){ IOUtils.copy(inputStream, new FileOutputStream(file)); } } AudioCaptureHelper(RapidFtrApplication context); void saveAudio(BaseModel baseModel, InputStream inputStream); String getCompleteFileName(String fileName);  }
@Test public void shouldSaveAudio() throws Exception { Child child = new Child("id1", "user1", "{ 'recorded_audio' : 'some_audio_file_name' }"); String data = "some audio stream 10101010"; InputStream inputStream = new ByteArrayInputStream(data.getBytes()); audioCaptureHelper.saveAudio(child, inputStream); assertTrue((new File(audioCaptureHelper.getDir(), "some_audio_file_name")).exists()); }