@Test
public void testStart() throws MediaPackageException, WorkflowOperationException {

  MediaPackage mediaPackage = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
  VideoStreamImpl videoStream = new VideoStreamImpl("234");
  videoStream.setFrameWidth(1280);
  videoStream.setFrameHeight(720);
  videoStream.setFrameRate(30.0f);
  TrackImpl track = new TrackImpl();
  track.setFlavor(MediaPackageElementFlavor.parseFlavor("presenter/source"));
  track.addStream(videoStream);
  JobContext jobContext = EasyMock.createMock(JobContext.class);
  EasyMock.replay(jobContext);
  WorkflowOperationInstance operationInstance = EasyMock.createMock(WorkflowOperationInstance.class);
  String[][] config = {
          {AnalyzeTracksWorkflowOperationHandler.OPT_SOURCE_FLAVOR, "*/source"},
          {AnalyzeTracksWorkflowOperationHandler.OPT_VIDEO_ASPECT, "4/3,16/9"}};
  for (String[] cfg: config) {
    EasyMock.expect(operationInstance.getConfiguration(cfg[0])).andReturn(cfg[1]).anyTimes();
  }
  EasyMock.expect(operationInstance.getConfiguration(AnalyzeTracksWorkflowOperationHandler.OPT_FAIL_NO_TRACK))
          .andReturn("true");
  EasyMock.expect(operationInstance.getConfiguration(AnalyzeTracksWorkflowOperationHandler.OPT_FAIL_NO_TRACK))
          .andReturn("false").anyTimes();
  EasyMock.replay(operationInstance);
  WorkflowInstance workflowInstance = EasyMock.createMock(WorkflowInstance.class);
  EasyMock.expect(workflowInstance.getMediaPackage()).andReturn(mediaPackage).anyTimes();
  EasyMock.expect(workflowInstance.getId()).andReturn(0L).anyTimes();
  EasyMock.expect(workflowInstance.getCurrentOperation()).andReturn(operationInstance).anyTimes();
  EasyMock.replay(workflowInstance);
  // With no matching track (should fail)
  try {
    operationHandler.start(workflowInstance, jobContext);
    fail();
  } catch (WorkflowOperationException e) {
    logger.info("Fail on no tracks works");
  }
  WorkflowOperationResult workflowOperationResult = operationHandler.start(workflowInstance, jobContext);
  Map<String, String> properties = workflowOperationResult.getProperties();
  assertTrue(properties.isEmpty());
  // With matching track
  mediaPackage.add(track);
  workflowOperationResult = operationHandler.start(workflowInstance, jobContext);
  properties = workflowOperationResult.getProperties();
  String[][] props = {
          {"presenter_source_media", "true"},
          {"presenter_source_audio", "false"},
          {"presenter_source_aspect", "16/9"},
          {"presenter_source_resolution_y", "720"},
          {"presenter_source_resolution_x", "1280"},
          {"presenter_source_aspect_snap", "16/9"},
          {"presenter_source_video", "true"},
          {"presenter_source_framerate", "30.0"}};
  for (String[] prop: props) {
    assertEquals(prop[1], properties.get(prop[0]));
  }
}