예제 #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"));
 }