@Test
public void testRetractPreviousElements() throws Exception {

  URI mpURI = LiveScheduleServiceImplTest.class.getResource("/live-mp.xml").toURI();
  MediaPackage previousMp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder()
          .loadFromXml(mpURI.toURL().openStream());
  MediaPackage newMp = (MediaPackage) previousMp.clone();
  // Change element url
  Catalog catalog = newMp.getCatalog("episode-dc-published");
  catalog.setURI(new URI("CHANGED/episode_dublincore.xml"));
  Job job = createJob(1L, "anything", "anything");
  Capture<Set<String>> capturedElementId = Capture.newInstance();
  EasyMock.expect(downloadDistributionService.retract(EasyMock.anyString(), EasyMock.anyObject(MediaPackage.class),
          EasyMock.capture(capturedElementId))).andReturn(job);
  EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job).anyTimes();
  replayServices();
  service.setDownloadDistributionService(downloadDistributionService);
  service.retractPreviousElements(previousMp, newMp);
  Set<String> ids = capturedElementId.getValue();
  Assert.assertEquals(1, ids.size());
  Assert.assertEquals("episode-dc-published", ids.iterator().next());
  EasyMock.verify(downloadDistributionService);
}