@Test
public void testHandleEvent() throws Exception {

  Catalog episodeCatalog = CatalogImpl.newInstance();
  episodeCatalog.setURI(URI.create("/episode.xml"));
  episodeCatalog.setFlavor(MediaPackageElementFlavor.parseFlavor("dublincore/episode"));
  episodeCatalog.addTag("archive");
  MediaPackage updatedMp = createMediaPackage(episodeCatalog);
  // these are the interactions we expect with the asset manager
  mockAssetManager(updatedMp);
  // these are the interactions we expect with the security service
  mockSecurityService();
  // these are the interactions we expect for the OAI-PMH database
  mockOaiPmhDatabase();
  Capture<MediaPackage> mpCapture = Capture.newInstance();
  Capture<String> repositoryCapture = Capture.newInstance();
  Capture<Set<String>> flavorsCapture = Capture.newInstance();
  Capture<Set> tagsCapture = Capture.newInstance();
  expect(oaiPmhPublicationService.updateMetadata(capture(mpCapture), capture(repositoryCapture),
          capture(flavorsCapture), capture(tagsCapture), anyBoolean()))
          .andAnswer(() -> mock(Job.class)).times(1);
  replayAll();
  cut.handleEvent(createSnapshot(updatedMp));
  assertEquals(updatedMp.getIdentifier().toString(), mpCapture.getValue().getIdentifier().toString());
  assertEquals(OAIPMH_REPOSITORY, repositoryCapture.getValue());
  Assert.assertNotNull(flavorsCapture.getValue());
  Assert.assertTrue(flavorsCapture.getValue().contains("dublincore/*"));
  Assert.assertTrue(flavorsCapture.getValue().contains("security/*"));
  Assert.assertTrue(tagsCapture.getValue().contains("archive"));
  Assert.assertTrue(orgIdCapture.hasCaptured());
  Assert.assertEquals(new DefaultOrganization().getId(), orgIdCapture.getValue());
  Assert.assertTrue(mpIdCapture.hasCaptured());
  Assert.assertEquals(updatedMp.getIdentifier().toString(), mpIdCapture.getValue());
  Assert.assertTrue(snapshotVersionCapture.hasCaptured());
  Assert.assertEquals("3", snapshotVersionCapture.getValue());
}