@Test
public void testEditorResume() throws WorkflowOperationException, URISyntaxException, NotFoundException, IOException,
        ProcessFailedException, ServiceRegistryException, MediaPackageException {

  // filled smil file
  URI episodeSmilURI = VideoEditorWorkflowOperationHandlerTest.class.getResource("/editor_smil_filled.smil").toURI();
  File episodeSmilFile = new File(episodeSmilURI);
  // setup mock services
  EasyMock.expect(workspaceMock.get((URI) EasyMock.anyObject())).andReturn(episodeSmilFile);
  EasyMock.expect(
          workspaceMock.put((String) EasyMock.anyObject(), (String) EasyMock.anyObject(),
                  (String) EasyMock.anyObject(), (InputStream) EasyMock.anyObject())).andReturn(episodeSmilURI);
  EasyMock.expect(
          workspaceMock.moveTo((URI) EasyMock.anyObject(), (String) EasyMock.anyObject(),
                  (String) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(
          URI.create("http://localhost:8080/foo/trimmed.mp4"));
  Job job = EasyMock.createNiceMock(Job.class);
  EasyMock.expect(job.getPayload()).andReturn(MediaPackageElementParser.getAsXml(mpSmil.getTracks()[0])).anyTimes();
  EasyMock.expect(job.getStatus()).andReturn(Job.Status.FINISHED);
  ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
  videoEditorWorkflowOperationHandler.setServiceRegistry(serviceRegistry);
  EasyMock.expect(serviceRegistry.getJob(EasyMock.anyLong())).andReturn(job);
  EasyMock.expect(videoEditorServiceMock.processSmil((Smil) EasyMock.anyObject())).andReturn(Arrays.asList(job));
  EasyMock.replay(workspaceMock, job, serviceRegistry, videoEditorServiceMock);
  WorkflowInstanceImpl workflowInstance = getWorkflowInstance(mpSmil, getDefaultConfiguration(true));
  // run test
  WorkflowOperationResult result = videoEditorWorkflowOperationHandler.resume(workflowInstance, null, null);
  Assert.assertNotNull(
          "VideoEditor workflow operation returns null but should be an instantiated WorkflowOperationResult", result);
  EasyMock.verify(workspaceMock, job, serviceRegistry, videoEditorServiceMock);
  // verify trimmed track derived from source track
  WorkflowOperationInstance worflowOperationInstance = workflowInstance.getCurrentOperation();
  String targetFlavorSubtypeProperty = worflowOperationInstance.getConfiguration("target-flavor-subtype");
  String sourceFlavorsProperty = worflowOperationInstance.getConfiguration("source-flavors");
  TrackSelector trackSelector = new TrackSelector();
  trackSelector.addFlavor(sourceFlavorsProperty);
  Collection<Track> sourceTracks = trackSelector.select(result.getMediaPackage(), false);
  Assert.assertTrue("Mediapackage does not contain any tracks matching flavor " + sourceFlavorsProperty,
          sourceTracks != null && !sourceTracks.isEmpty());
  for (Track sourceTrack : sourceTracks) {
    MediaPackageElementFlavor targetFlavor = MediaPackageElementFlavor.flavor(sourceTrack.getFlavor().getType(),
            targetFlavorSubtypeProperty);
    Track[] targetTracks = result.getMediaPackage().getTracks(targetFlavor);
    Assert.assertTrue("Media package doesn't contain track with flavor " + targetFlavor.toString(),
            targetTracks != null && targetTracks.length > 0);
  }
}