Ejemplo n.º 1
0
  @Test
  public void testGetMostRecentEvent() {

    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);

    // assert newest to oldest
    assertEquals(e2, manager.getMostRecentEvent("1"));
  }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
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());
  }
Ejemplo n.º 5
0
 @Test
 public void testGetMostRecentEventUnknownSource() {
   EventManager manager = new EventManagerImpl(1);
   assertNull(manager.getMostRecentEvent("unknown value"));
 }
Ejemplo n.º 6
0
 @Test
 public void testGetEventsUnknownSource() {
   EventManager manager = new EventManagerImpl(1);
   assertEquals(Collections.EMPTY_LIST, manager.getEvents("unknown value"));
 }