public void test(NotificationDto notificationDto, String userName) throws NotFoundException, InternalServerErrorException {
        NotificationDto dto = prepareUpdate(notificationDto);
        final EventNotification.Factory eventNotificationFactory = eventNotificationFactories.get(dto.config().type());
        if (eventNotificationFactory == null) {
            throw new NotFoundException("Couldn't find factory for notification type <" + dto.config().type() + ">");
        }
        final EventNotificationContext notificationContext = NotificationTestData.getDummyContext(dto, userName);
        final EventNotification eventNotification = eventNotificationFactory.create();
        try {
            eventNotification.execute(notificationContext);
        } catch (EventNotificationException e) {
            if (e.getCause() != null) {
                throw new InternalServerErrorException(e.getCause().getMessage(), e);
            } else {
                throw new InternalServerErrorException(e.getMessage(), e);
            }
        }
    }
@Test
    public void testExecution() throws EventNotificationException {
        notificationResourceHandler.test(getHttpNotification(), "testUser");

        ArgumentCaptor<EventNotificationContext> captor = ArgumentCaptor.forClass(EventNotificationContext.class);
        verify(eventNotification, times(1)).execute(captor.capture());

        assertThat(captor.getValue()).satisfies(ctx -> {
            assertThat(ctx.event().message()).isEqualTo("Notification test message triggered from user <testUser>");
            assertThat(ctx.notificationId()).isEqualTo(NotificationTestData.TEST_NOTIFICATION_ID);
            assertThat(ctx.notificationConfig().type()).isEqualTo(HTTPEventNotificationConfig.TYPE_NAME);
            assertThat(ctx.eventDefinition().get().title()).isEqualTo("Event Definition Test Title");
        });
    }