@Test
public void testAddMultipleEvents() throws Exception {

  final RRule rrule = new RRule("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;BYHOUR=7;BYMINUTE=0");
  final Date start = new Date(1546844400000L); // 2019-01-07T07:00:00Z
  final Date end = new Date(1570953300000L); // 2019-10-13T07:55:00Z
  final Long duration = 6900000L;
  final TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
  final String captureAgentId = "Device A";
  final Set<String> userIds = Collections.emptySet();
  final String id = "Recording1";
  final String seriesId = "TestSeries";
  final MediaPackage mpTemplate = generateEvent(Opt.some(id));
  mpTemplate.setSeries(seriesId);
  final DublinCoreCatalog dublinCoreCatalog = generateEvent(captureAgentId, Opt.some(mpTemplate.getIdentifier().toString()), Opt.some("Test Title"), start, end);
  addDublinCore(Opt.some(mpTemplate.getIdentifier().toString()), mpTemplate, dublinCoreCatalog);
  final Map<String, String> wfProperties = this.wfProperties;
  final Map<String, String> caProperties = Collections.singletonMap("foo", "bar");
  final Opt<String> schedulingSource = Opt.none();
  assertEquals("mod0", schedSvc.getScheduleLastModified(captureAgentId));
  final Map<String, Period> scheduled = schedSvc.addMultipleEvents(
      rrule,
      start,
      end,
      duration,
      tz,
      captureAgentId,
      userIds,
      mpTemplate,
      wfProperties,
      caProperties,
      schedulingSource
  );
  final int expectedEventCount = rrule.getRecur().getDates(
      new net.fortuna.ical4j.model.Date(start),
      new net.fortuna.ical4j.model.Date(end),
      Value.DATE
  ).size();
  assertEquals(expectedEventCount, scheduled.keySet().size());
  final String randomMpId = scheduled.keySet().stream().findAny().orElseThrow(() -> new RuntimeException("This should never happen"));
  final Period period = scheduled.get(randomMpId);
  final MediaPackage mediaPackage = schedSvc.getMediaPackage(randomMpId);
  final DublinCoreCatalog eventLoaded = schedSvc.getDublinCore(randomMpId);
  final TechnicalMetadata technicalMetadata = schedSvc.getTechnicalMetadata(randomMpId);
  assertEquals(seriesId, mediaPackage.getSeries());
  assertTrue(eventLoaded.getFirst(PROPERTY_TITLE).startsWith(dublinCoreCatalog.getFirst(PROPERTY_TITLE)));
  assertEquals(randomMpId, technicalMetadata.getEventId());
  assertEquals(captureAgentId, technicalMetadata.getAgentId());
  assertEquals(new Date(period.getStart().getTime()), technicalMetadata.getStartDate());
  assertEquals(new Date(period.getEnd().getTime()), technicalMetadata.getEndDate());
  assertEquals(userIds, technicalMetadata.getPresenters());
  assertTrue(technicalMetadata.getRecording().isNone());
  assertTrue(technicalMetadata.getCaptureAgentConfiguration().size() >= caProperties.size());
  assertEquals(wfProperties, new HashMap<>(schedSvc.getWorkflowConfig(randomMpId)));
  String lastModified = schedSvc.getScheduleLastModified(captureAgentId);
  assertNotEquals("mod0", lastModified);
  assertTrue(schedSvc.getCaptureAgentConfiguration(randomMpId).size() >= caProperties.size());
}