Пример #1
0
  @Test
  public void testAddEventExceedsHistorySize() {

    EventManager manager = new EventManagerImpl(1);

    Event e1 = new Event("1", "Event1", Category.INFO, 0);
    Event e2 = new Event("1", "Event2", Category.INFO, 1);

    manager.addEvent(e1);
    manager.addEvent(e2);

    List<Event> events = manager.getEvents("1");

    // assert oldest evicted
    assertEquals(Arrays.asList(e2), events);
  }
Пример #2
0
  @Test
  public void testGetEvents() {

    EventManager manager = new EventManagerImpl(2);

    Event e1 = new Event("1", "Event1", Category.INFO, 0);
    Event e2 = new Event("1", "Event2", Category.INFO, 1);

    manager.addEvent(e1);
    manager.addEvent(e2);

    List<Event> events = manager.getEvents("1");

    // assert newest to oldest
    assertEquals(Arrays.asList(e2, e1), events);
  }
Пример #3
0
  @Test
  public void testClearHistory() {

    EventManager manager = new EventManagerImpl(1);

    Event e1 = new Event("1", "Event1", Category.INFO, 0);
    Event e2 = new Event("1", "Event2", Category.INFO, 1);

    manager.addEvent(e1);
    manager.addEvent(e2);

    manager.clearEventHistory("1");

    // assert oldest evicted
    assertTrue(manager.getEvents("1").isEmpty());
  }
Пример #4
0
 @Test
 public void testGetEventsUnknownSource() {
   EventManager manager = new EventManagerImpl(1);
   assertEquals(Collections.EMPTY_LIST, manager.getEvents("unknown value"));
 }