use of io.kubernetes.client.extended.event.legacy.EventCorrelator in project java by kubernetes-client.
the class EventCorrelatorTest method testEventCorrelate.
@Test
public void testEventCorrelate() throws InterruptedException {
EventCorrelator correlator = new EventCorrelator();
for (CoreV1Event event : previousEvents) {
OffsetDateTime now = OffsetDateTime.now();
event.setFirstTimestamp(now);
event.setLastTimestamp(now);
Optional<MutablePair<CoreV1Event, V1Patch>> result = correlator.correlate(event);
if (!result.isPresent()) {
correlator.updateState(event);
}
}
Thread.sleep(100);
OffsetDateTime now = OffsetDateTime.now();
newEvent.setFirstTimestamp(now);
newEvent.setLastTimestamp(now);
Optional<MutablePair<CoreV1Event, V1Patch>> result = correlator.correlate(newEvent);
assertEquals(expectedSkip, !result.isPresent());
if (!expectedSkip) {
CoreV1Event correlatedEvent = result.get().getLeft();
correlatedEvent.setMetadata(new V1ObjectMetaBuilder().withName("").withNamespace("").build());
validateEvent(expectedEvent, correlatedEvent);
}
}
Aggregations