@Test
public void testTranscriptionDone() throws Exception {

  InputStream stream = GoogleSpeechTranscriptionServiceTest.class.getResourceAsStream("/" + PULLED_TRANSCRIPTION_FILE);
  database.storeJobControl(MP_ID, TRACK_ID, JOB_ID, TranscriptionJobControl.Status.InProgress.name(), TRACK_DURATION, DATE_EXPECTED, PROVIDER);
  JSONObject obj = (JSONObject) jsonParser.parse(new InputStreamReader(stream));
  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);
  long before = System.currentTimeMillis();
  service.transcriptionDone(MP_ID, obj);
  long after = System.currentTimeMillis();
  // Check if status and date in db was updated
  TranscriptionJobControl job = database.findByJob(JOB_ID);
  Assert.assertNotNull(job);
  Assert.assertEquals(TranscriptionJobControl.Status.TranscriptionComplete.name(), job.getStatus());
  Assert.assertNotNull(job.getDateCompleted());
  Assert.assertTrue(before <= job.getDateCompleted().getTime() && job.getDateCompleted().getTime() <= after);
  // Check if results were saved into a collection
  Assert.assertEquals(GoogleSpeechTranscriptionService.TRANSCRIPT_COLLECTION, capturedCollection.getValue());
  Assert.assertEquals(JOB_ID + ".json", capturedFileName.getValue());
}