@Test
public void testGetKnownRecordings() throws Exception {

  final long oneHourMillis = 3600_000;
  final long nowMillis = new Date().getTime();
  final String mpId = "mpId";
  final String agentId = "agent1";
  final String orgId = new DefaultOrganization().getId();
  final Date intervalEnd = new Date(nowMillis + 5 * oneHourMillis);
  final Date[] eventStartDates = {
      new Date(nowMillis - 4 * oneHourMillis),
      new Date(nowMillis - oneHourMillis),
      new Date(nowMillis + oneHourMillis),
      new Date(intervalEnd.getTime()),
  };
  final String recordingState = "recordingState";
  final Long lastHeard = new Date().getTime();
  for (int i = 0; i < 4; i++) {
    final Date start = eventStartDates[i];
    final Date end = new Date(start.getTime() + 2 * oneHourMillis);
    schedulerDatabase.storeEvent(
        mpId + i,
        orgId,
        Opt.some(agentId),
        Opt.some(start),
        Opt.some(end),
        Opt.none(),
        i % 2 == 0 ? Opt.some(recordingState) : Opt.none(),
        i % 2 == 0 ? Opt.some(lastHeard) : Opt.none(),
        Opt.none(),
        Opt.none(),
        Opt.none(),
        Opt.none(),
        Opt.none()
    );
  }
  final List<ExtendedEventDto> knownEvents = schedulerDatabase.getKnownRecordings();
  Assert.assertEquals(2, knownEvents.size());
  Assert.assertTrue(knownEvents.get(0).getMediaPackageId().equals(mpId + 0)
      || knownEvents.get(1).getMediaPackageId().equals(mpId + 0));
  Assert.assertTrue(knownEvents.get(0).getMediaPackageId().equals(mpId + 2)
      || knownEvents.get(1).getMediaPackageId().equals(mpId + 2));
}