Mono<Void> dispatchNotification(Reason reason, Subscriber subscriber) {
        return getNotifiersBySubscriber(subscriber, reason)
            .flatMap(notifierName -> client.fetch(NotifierDescriptor.class, notifierName))
            .flatMap(descriptor -> prepareNotificationElement(subscriber, reason, descriptor))
            .flatMap(element -> {
                var dispatchMono = sendNotification(element);
                if (subscriber.isAnonymous()) {
                    return dispatchMono;
                }
                // create notification for user
                var innerNofificationMono = createNotification(element);
                return Mono.when(dispatchMono, innerNofificationMono);
            })
            .then();
    }
@Test
    public void testDispatchNotification() {
        var spyNotificationCenter = spy(notificationCenter);

        doReturn(Flux.just("email-notifier"))
            .when(spyNotificationCenter).getNotifiersBySubscriber(any(), any());

        NotifierDescriptor notifierDescriptor = mock(NotifierDescriptor.class);
        when(client.fetch(eq(NotifierDescriptor.class), eq("email-notifier")))
            .thenReturn(Mono.just(notifierDescriptor));

        var notificationElement = mock(DefaultNotificationCenter.NotificationElement.class);
        doReturn(Mono.just(notificationElement))
            .when(spyNotificationCenter).prepareNotificationElement(any(), any(), any());

        doReturn(Mono.empty()).when(spyNotificationCenter).sendNotification(any());

        var reason = new Reason();
        reason.setMetadata(new Metadata());
        reason.getMetadata().setName("reason-a");
        reason.setSpec(new Reason.Spec());
        reason.getSpec().setReasonType("new-reply-on-comment");

        var subscription = createSubscriptions().get(0);
        var subscriptionName = subscription.getMetadata().getName();
        var subscriber =
            new Subscriber(UserIdentity.of(subscription.getSpec().getSubscriber().getName()),
                subscriptionName);
        spyNotificationCenter.dispatchNotification(reason, subscriber).block();

        verify(client).fetch(eq(NotifierDescriptor.class), eq("email-notifier"));
        verify(spyNotificationCenter).sendNotification(any());
        verify(spyNotificationCenter, times(0)).createNotification(any());
    }