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

  Map<String, String> wfInstConfig = new Hashtable<>();
  wfInstConfig.put(CleanupWorkflowOperationHandler.PRESERVE_FLAVOR_PROPERTY, "*/source,smil/trimmed,security/*");
  wfInstConfig.put(CleanupWorkflowOperationHandler.DELETE_EXTERNAL, "true");
  MediaPackageBuilder mpBuilder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
  MediaPackage mp = mpBuilder.createNew();
  MediaPackageElement track1 = addElementToMediaPackage(mp, MediaPackageElement.Type.Track,
          "presenter", "source", null);
  track1.setURI(UrlSupport.uri(HOSTNAME_NODE1, WFR_URL_PREFIX, WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX,
          mp.getIdentifier().toString(), track1.getIdentifier(), "track.mp4"));
  MediaPackageElement track2 = addElementToMediaPackage(mp, MediaPackageElement.Type.Track,
          "presentation", "work", null);
  track2.setURI(UrlSupport.uri(HOSTNAME_NODE2, WFR_URL_PREFIX, WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX,
          mp.getIdentifier().toString(), track2.getIdentifier(), "track.mp4"));
  MediaPackageElement att1 = addElementToMediaPackage(mp, MediaPackageElement.Type.Attachment,
          "presentation", "preview", null);
  att1.setURI(UrlSupport.uri(HOSTNAME_NODE2, WFR_URL_PREFIX, WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX,
          mp.getIdentifier().toString(), att1.getIdentifier(), "preview.png"));
  MediaPackageElement att2 = addElementToMediaPackage(mp, MediaPackageElement.Type.Attachment,
          "smil", "trimmed", null);
  att2.setURI(UrlSupport.uri(HOSTNAME_NODE1, WFR_URL_PREFIX, WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX,
          mp.getIdentifier().toString(), att2.getIdentifier(), "trimmed.smil"));
  MediaPackageElement cat1 = addElementToMediaPackage(mp, MediaPackageElement.Type.Catalog,
          "dublincore", "episode", null);
  cat1.setURI(UrlSupport.uri(HOSTNAME_NODE1, WFR_URL_PREFIX, WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX,
          mp.getIdentifier().toString(), cat1.getIdentifier(), "dublincore.xml"));
  MediaPackageElement cat2 = addElementToMediaPackage(mp, MediaPackageElement.Type.Catalog,
          "security", "xaml", null);
  cat2.setURI(UrlSupport.uri(HOSTNAME_NODE1, WFR_URL_PREFIX, WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX,
          mp.getIdentifier().toString(), cat2.getIdentifier(), "security.xml"));
  cleanupWOH.start(createWorkflowInstance(wfInstConfig, mp), null);
  Assert.assertEquals("Media package should contain at least tree elements", 3, mp.getElements().length);
  SimpleElementSelector elementSelector = new SimpleElementSelector();
  elementSelector.addFlavor("*/source");
  Assert.assertFalse("Media package doesn't contain an element with a preserved flavor '*/source'",
          elementSelector.select(mp, false).isEmpty());
  elementSelector = new SimpleElementSelector();
  elementSelector.addFlavor("smil/trimmed");
  Assert.assertFalse("Media package doesn't contain an element with a preserved flavor 'smil/trimmed'",
          elementSelector.select(mp, false).isEmpty());
  elementSelector = new SimpleElementSelector();
  elementSelector.addFlavor("security/*");
  Assert.assertFalse("Media package doesn't contain an element with a preserved flavor 'security/*'",
          elementSelector.select(mp, false).isEmpty());
  Assert.assertEquals("At least one file wasn't deleted on remote repository", 3, deletedFilesURIs.size());
}