use of io.kubernetes.client.extended.event.legacy.EventAggregator in project java by kubernetes-client.
the class EventAggregatorTest method testSpammingEventsShouldBeAggregated.
@Test
public void testSpammingEventsShouldBeAggregated() {
String aggregatedMessage = "noxu";
EventAggregator aggregator = new EventAggregator(100, EventUtils::getAggregatedAndLocalKeyByReason, event -> aggregatedMessage);
for (int i = 0; i < aggregator.getMaxEvents() - 1; i++) {
String message = aggregator.aggregate(new CoreV1EventBuilder().withSource(new V1EventSource()).withInvolvedObject(new V1ObjectReference()).withMessage("foo: " + i).build()).getLeft().getMessage();
assertNotEquals(aggregatedMessage, message);
}
CoreV1Event aggregatedEvent = aggregator.aggregate(new CoreV1EventBuilder().withSource(new V1EventSource()).withInvolvedObject(new V1ObjectReference()).withMessage("not_noxu").build()).getLeft();
assertEquals(aggregatedMessage, aggregatedEvent.getMessage());
}
Aggregations