@Test
public void testCreateRecognitionsJob() throws Exception {

  InputStream stream = GoogleSpeechTranscriptionServiceTest.class.getResourceAsStream("/" + IN_PROGRESS_JOB);
  Capture<String> capturedCollection = Capture.newInstance();
  Capture<String> capturedFileName = Capture.newInstance();
  EasyMock.expect(workspace.putInCollection(EasyMock.capture(capturedCollection), EasyMock.capture(capturedFileName),
          EasyMock.anyObject(InputStream.class))).andReturn(new URI("http://anything"));
  EasyMock.replay(workspace);
  HttpEntity httpEntity = EasyMock.createNiceMock(HttpEntity.class);
  EasyMock.expect(httpEntity.getContent()).andReturn(stream);
  CloseableHttpResponse response = EasyMock.createNiceMock(CloseableHttpResponse.class);
  StatusLine status1 = EasyMock.createNiceMock(StatusLine.class);
  EasyMock.expect(response.getStatusLine()).andReturn(status1).anyTimes();
  EasyMock.expect(response.getEntity()).andReturn(httpEntity).anyTimes();
  EasyMock.expect(status1.getStatusCode()).andReturn(HttpStatus.SC_OK).anyTimes();
  EasyMock.replay(httpEntity, response, status1);
  Capture<HttpPost> capturedPost = Capture.newInstance();
  EasyMock.expect(httpClient.execute(EasyMock.capture(capturedPost))).andReturn(response).anyTimes();
  EasyMock.replay(httpClient);
  service.createRecognitionsJob(MP_ID, mediaPackage.getTrack("audioTrack1"), LANGUAGE_CODE);
  Assert.assertEquals("https://speech.googleapis.com/v1/speech:longrunningrecognize",
          capturedPost.getValue().getURI().toString());
  TranscriptionJobControl j = database.findByJob(JOB_ID);
  Assert.assertNotNull(j);
  Assert.assertEquals(MP_ID, j.getMediaPackageId());
  Assert.assertEquals(TRACK_ID, j.getTrackId());
  Assert.assertEquals(TranscriptionJobControl.Status.InProgress.name(), j.getStatus());
}