@Test
public void testCreateLiveEvent() throws Exception {

  URI mpURI = LiveScheduleServiceImplTest.class.getResource("/assetmanager-mp.xml").toURI();
  MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder()
          .loadFromXml(mpURI.toURL().openStream());
  setUpAssetManager(mp);
  URI catalogURI = LiveScheduleServiceImplTest.class.getResource("/episode.xml").toURI();
  DublinCoreCatalog episodeDC = DublinCores.read(catalogURI.toURL().openStream());
  catalogURI = LiveScheduleServiceImplTest.class.getResource("/series.xml").toURI();
  DublinCoreCatalog seriesDC = DublinCores.read(catalogURI.toURL().openStream());
  EasyMock.expect(seriesService.getSeries(SERIES_ID)).andReturn(seriesDC).anyTimes();
  Job job = createJob(1L, "anything", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
          + "<catalog id=\"9ad6ebcb-b414-4b15-ab62-5e5ddede447e\" type=\"dublincore/episode\" xmlns=\"http://mediapackage.opencastproject.org\">"
          + "<mimetype>text/xml</mimetype>"
          + "<url>http://10.10.10.50/static/mh_default_org/engage-live/episode.xml</url></catalog>"
          + "###<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
          + "<catalog id=\"23113662-1a84-457a-85d5-0b3e32d2413a\" type=\"dublincore/series\" xmlns=\"http://mediapackage.opencastproject.org\">"
          + "<mimetype>text/xml</mimetype>"
          + "<url>http://10.10.10.50/static/mh_default_org/engage-live/series.xml</url></catalog>"
          + "###<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
          + "<attachment id=\"security-policy-episode\" type=\"security/xacml+episode\" xmlns=\"http://mediapackage.opencastproject.org\">"
          + "<mimetype>text/xml</mimetype>"
          + "<url>http://10.10.10.50/static/mh_default_org/engage-live/security_policy_episode.xml</url></attachment>");
  EasyMock.expect(downloadDistributionService.distribute(EasyMock.anyString(), EasyMock.anyObject(MediaPackage.class),
          EasyMock.anyObject(Set.class), EasyMock.anyBoolean())).andReturn(job);
  EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job).anyTimes();
  Job jobPub = createJob(2L, "anything", "anything");
  Capture<MediaPackage> capturedMp = Capture.newInstance();
  EasyMock.expect(searchService.add(EasyMock.capture(capturedMp))).andReturn(jobPub);
  EasyMock.expect(serviceRegistry.getJob(2L)).andReturn(job).anyTimes();
  Capture<MediaPackage> capturedSnapshotMp = Capture.newInstance();
  Version v = EasyMock.createNiceMock(Version.class);
  Snapshot s = EasyMock.createNiceMock(Snapshot.class);
  EasyMock.expect(s.getVersion()).andReturn(v);
  EasyMock.replay(s, v);
  EasyMock.expect(
          assetManager.takeSnapshot(EasyMock.capture(capturedSnapshotMp))).andReturn(s);
  replayServices();
  service.setDownloadDistributionService(downloadDistributionService);
  service.createLiveEvent(MP_ID, episodeDC);
  // Check published live media package
  MediaPackage searchMp = capturedMp.getValue();
  Assert.assertEquals(MP_ID, searchMp.getIdentifier().toString());
  Assert.assertEquals(DURATION, searchMp.getDuration().longValue());
  Assert.assertEquals(2, searchMp.getCatalogs().length);
  assertExpectedLiveTracks(searchMp.getTracks(), DURATION, CAPTURE_AGENT_NAME, "_suffix", false);
  // Check archived media package
  MediaPackage archivedMp = capturedSnapshotMp.getValue();
  Assert.assertEquals(MP_ID, archivedMp.getIdentifier().toString());
  Assert.assertEquals(1, archivedMp.getPublications().length);
  Assert.assertEquals(LiveScheduleService.CHANNEL_ID, archivedMp.getPublications()[0].getChannel());
  Assert.assertEquals(v, service.getSnapshotVersionCache().getIfPresent(MP_ID)); // Check that version got into local cache
}