@Test
public void testUpdateEvent() throws Exception {

  final long currentTime = System.currentTimeMillis();
  final String initialTitle = "Recording 1";
  final DublinCoreCatalog initalEvent = generateEvent("Device A", Opt.<String> none(), Opt.some(initialTitle),
          new Date(currentTime + 10 * 1000), new Date(currentTime + 3610000));
  MediaPackage mediaPackage = generateEvent(Opt.<String> none());
  String elementId = addDublinCore(Opt.<String> none(), mediaPackage, initalEvent);
  Map<String, String> caProperties = map(tuple("org.opencastproject.workflow.definition", "full"));
  schedSvc.addEvent(new Date(currentTime + 10 * 1000), new Date(currentTime + 3610000), "Device A",
          Collections.<String> emptySet(), mediaPackage, wfProperties, caProperties, Opt.<String> none());
  Map<String, String> initalCaProps = schedSvc.getCaptureAgentConfiguration(mediaPackage.getIdentifier().toString());
  checkEvent(mediaPackage.getIdentifier().toString(), initalCaProps, initialTitle);
  // do single update
  final String updatedTitle1 = "Recording 2";
  final DublinCoreCatalog updatedEvent1 = generateEvent("Device A", Opt.some(mediaPackage.getIdentifier().toString()),
          Opt.some(updatedTitle1), new Date(currentTime + 10 * 1000), new Date(currentTime + 3610000));
  addDublinCore(Opt.some(elementId), mediaPackage, updatedEvent1);
  schedSvc.updateEvent(mediaPackage.getIdentifier().toString(), Opt.<Date> none(), Opt.<Date> none(),
          Opt.<String> none(), Opt.<Set<String>> none(), Opt.some(mediaPackage), Opt.some(wfPropertiesUpdated),
          Opt.<Map<String, String>> none());
  final Map<String, String> updatedCaProps = new HashMap<>(initalCaProps);
  updatedCaProps.put("event.title", updatedTitle1);
  updatedCaProps.put("org.opencastproject.workflow.config.test", "false");
  updatedCaProps.put("org.opencastproject.workflow.config.skip", "true");
  updatedCaProps.remove("org.opencastproject.workflow.config.clear");
  // copy to new HashMap since returned map wrapper does not delegate hashcode and equals
  assertEquals("CA properties", updatedCaProps,
          new HashMap<>(schedSvc.getCaptureAgentConfiguration(mediaPackage.getIdentifier().toString())));
  assertEquals("DublinCore title", updatedTitle1,
          schedSvc.getDublinCore(mediaPackage.getIdentifier().toString()).getFirst(PROPERTY_TITLE));
  checkIcalFeed(updatedCaProps, updatedTitle1);
}