@Test
public void testPublish() throws MediaPackageException, 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.Publish.toString()),
          capture(jobArgsCapture))).andReturn(dummyJob).once();
  EasyMock.replay(serviceRegistry);
  service.setServiceRegistry(serviceRegistry);
  Job j = service.publish(mp, "default",
          Collections.set("catalog-1", "catalog-2", "track-1"), Collections.set("track-1"),true);
  Assert.assertSame(dummyJob, j);
  List<String> jobArgs = jobArgsCapture.getValue();
  // test job arguments
  Assert.assertEquals(5, jobArgs.size());
  Assert.assertTrue(jobArgs.get(0).contains("<mediapackage "));
  Assert.assertEquals("default", jobArgs.get(1));
  String downloadDistributionIdsArg = jobArgs.get(2);
  Assert.assertNotNull(downloadDistributionIdsArg);
  Assert.assertTrue(downloadDistributionIdsArg.contains("catalog-1"));
  Assert.assertTrue(downloadDistributionIdsArg.contains("catalog-2"));
  Assert.assertTrue(downloadDistributionIdsArg.contains("track-1"));
  String streamingDistributionIdsArg = jobArgs.get(3);
  Assert.assertNotNull(streamingDistributionIdsArg);
  Assert.assertTrue(!streamingDistributionIdsArg.contains("catalog-1"));
  Assert.assertTrue(!streamingDistributionIdsArg.contains("catalog-2"));
  Assert.assertTrue(streamingDistributionIdsArg.contains("track-1"));
  Assert.assertTrue(BooleanUtils.toBoolean(jobArgs.get(4)));
}