ResourceType resourceType = new ResourceType("foo", "foo", ResourceCategory.PLATFORM, null);
Resource resource = new Resource(1);
EventDefinition eventDefinition = new EventDefinition(resourceType, "foo");
EventSource eventSource = new EventSource("foo", eventDefinition, resource);
EventReport report = new EventReport(10, 10);
report.addEvent(new Event("foo", "foo", 0, EventSeverity.DEBUG, "foo-first", eventSource), eventSource);
report.addLimitWarningEvents(); // should do nothing
Map<EventSource, Set<Event>> allEvents = report.getEvents();
assert allEvents.size() == 1;
assert allEvents.get(eventSource).size() == 1;
report.addEvent(new Event("foo", "foo", 1, EventSeverity.DEBUG, "foo-second", eventSource), eventSource);
report.addLimitWarningEvents(); // should do nothing
allEvents = report.getEvents();
assert allEvents.size() == 1; // only one event source still!
assert allEvents.get(eventSource).size() == 2;
// make sure they are the ones we expect
for (Event e : allEvents.get(eventSource)) {
assert e.getDetail().startsWith("foo-");
}
// use a second event source
EventSource eventSource2 = new EventSource("bar", eventDefinition, resource);
report.addEvent(new Event("bar", "bar", 2, EventSeverity.DEBUG, "bar-first", eventSource2), eventSource2);
report.addLimitWarningEvents(); // should do nothing
allEvents = report.getEvents();
assert allEvents.size() == 2;
assert allEvents.get(eventSource).size() == 2;
assert allEvents.get(eventSource2).size() == 1;