@Test
public void testUpdateMetadata() throws PublicationException, ServiceRegistryException, MediaPackageException {

  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.UpdateMetadata.toString()),
          capture(jobArgsCapture))).andReturn(dummyJob).once();
  EasyMock.replay(serviceRegistry);
  service.setServiceRegistry(serviceRegistry);
  Set<String> flavorsSet = Collections.set("dublincore/*", "security/*");
  Set<String> tagsSet = Collections.set("archive", "other");
  Job j = service.updateMetadata(mp, "default", flavorsSet, tagsSet, true);
  Assert.assertSame(dummyJob, j);
  // test job arguments
  List<String> jobArgs = jobArgsCapture.getValue();
  Assert.assertEquals(5, jobArgs.size());
  Assert.assertTrue(jobArgs.get(0).contains("<mediapackage "));
  Assert.assertEquals("default", jobArgs.get(1));
  Assert.assertEquals(StringUtils.join(flavorsSet, OaiPmhPublicationServiceImpl.SEPARATOR), jobArgs.get(2));
  Assert.assertEquals(StringUtils.join(tagsSet, OaiPmhPublicationServiceImpl.SEPARATOR), jobArgs.get(3));
  Assert.assertTrue(Boolean.valueOf(jobArgs.get(4)));
}