OaiPmhPublicationServiceImpl extends AbstractJobProducer implements OaiPmhPublicationService { @Override public Job retract(MediaPackage mediaPackage, String repository) throws PublicationException, NotFoundException { checkInputArguments(mediaPackage, repository); try { return serviceRegistry.createJob(JOB_TYPE, Operation.Retract.toString(), Arrays.asList(MediaPackageParser.getAsXml(mediaPackage), repository)); } catch (ServiceRegistryException e) { throw new PublicationException("Unable to create job", e); } } OaiPmhPublicationServiceImpl(); @Override Job replace(MediaPackage mediaPackage, String repository, Set<? extends MediaPackageElement> downloadElements,
         Set<? extends MediaPackageElement> streamingElements, Set<MediaPackageElementFlavor> retractDownloadFlavors,
         Set<MediaPackageElementFlavor> retractStreamingFlavors, Set<? extends Publication> publications,
         boolean checkAvailability); @Override Publication replaceSync(
      MediaPackage mediaPackage, String repository, Set<? extends MediaPackageElement> downloadElements,
      Set<? extends MediaPackageElement> streamingElements, Set<MediaPackageElementFlavor> retractDownloadFlavors,
      Set<MediaPackageElementFlavor> retractStreamingFlavors, Set<? extends Publication> publications,
      boolean checkAvailability); @Override Job publish(MediaPackage mediaPackage, String repository, Set<String> downloadElementIds,
          Set<String> streamingElementIds, boolean checkAvailability); @Override Job retract(MediaPackage mediaPackage, String repository); @Override Job updateMetadata(MediaPackage mediaPackage, String repository, Set<String> flavors, Set<String> tags,
          boolean checkAvailability); static MediaPackage removeMatchingNonExistantElements(MediaPackage updatedMp, MediaPackage publishedMp,
          Set<MediaPackageElementFlavor> flavors, Set<String> tags); static MediaPackage merge(MediaPackage updatedMp, MediaPackage publishedMp); void setServiceRegistry(ServiceRegistry serviceRegistry); void setSecurityService(SecurityService securityService); void setUserDirectoryService(UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService); void setDownloadDistributionService(DownloadDistributionService downloadDistributionService); void setStreamingDistributionService(StreamingDistributionService streamingDistributionService); void setOaiPmhServerInfo(OaiPmhServerInfo oaiPmhServerInfo); void setOaiPmhDatabase(OaiPmhDatabase oaiPmhDatabase);  }
@Test public void testRetract() throws NotFoundException, PublicationException, ServiceRegistryException { ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class); Job dummyJob = EasyMock.createMock(Job.class); Capture<List<String>> jobArgsCapture = EasyMock.newCapture(); EasyMock.expect(serviceRegistry.createJob( eq(OaiPmhPublicationService.JOB_TYPE), eq(OaiPmhPublicationServiceImpl.Operation.Retract.toString()), capture(jobArgsCapture))).andReturn(dummyJob).once(); EasyMock.replay(serviceRegistry); service.setServiceRegistry(serviceRegistry); Job j = service.retract(mp2, "default"); Assert.assertSame(dummyJob, j); List<String> jobArgs = jobArgsCapture.getValue(); Assert.assertEquals(2, jobArgs.size()); Assert.assertTrue(jobArgs.get(0).contains("<mediapackage ")); Assert.assertEquals("default", jobArgs.get(1)); }