feat(event): Add unregisterAll method to EventService and EventHandlerRegistry

This commit is contained in:
extio-de
2025-12-26 15:57:57 +01:00
parent a9ddcb173d
commit 64adf9c9f9
4 changed files with 28 additions and 0 deletions

View File

@@ -107,6 +107,21 @@ class EventServiceTest {
.untilAsserted(() -> assertThat(this.receivedEvents).isEmpty());
}
@Test
void testUnregisterAll() throws InterruptedException {
this.eventService.register(TestEvent.class, "consumer1", event -> this.receivedEvents.add(event));
this.eventService.register(OtherTestEvent.class, "consumer1", event -> this.receivedEvents.add(event));
this.eventService.unregisterAll("consumer1");
this.eventService.fire(new TestEvent("test"));
this.eventService.fire(new OtherTestEvent("other"));
await().pollDelay(Duration.ofMillis(50))
.atMost(Duration.ofMillis(200))
.untilAsserted(() -> assertThat(this.receivedEvents).isEmpty());
}
@Test
void testConsumerReregistration() throws InterruptedException {
final var firstLatch = new CountDownLatch(1);