Search in sources :

Example 1 with DefaultValidationNotificationService

use of org.hisp.dhis.validation.notification.DefaultValidationNotificationService in project dhis2-core by dhis2.

the class ValidationNotificationServiceTest method initTest.

/*
     * Configure org unit hierarchy like so:
     *
     * Root / \ lvlOneLeft lvlOneRight / \ lvlTwoLeftLeft lvlTwoLeftRight
     */
/**
 * We mock the sending of messages to write to a local List (which we can
 * inspect). Also, the renderer is replaced with a mock which returns a
 * static subject/message-pair.
 */
@BeforeEach
void initTest() {
    subject = new DefaultValidationNotificationService(renderer, messageService, validationResultService);
    this.periodService = new DefaultPeriodService(periodStore);
    sentMessages = new ArrayList<>();
    when(messageService.sendValidationMessage(anySet(), anyString(), anyString(), any(MessageConversationPriority.class))).then(invocation -> {
        sentMessages.add(new MockMessage(invocation.getArguments()));
        return 42L;
    });
    // Stub renderer
    when(renderer.render(any(), any())).thenReturn(new NotificationMessage(STATIC_MOCK_SUBJECT, STATIC_MOCK_MESSAGE));
}
Also used : NotificationMessage(org.hisp.dhis.notification.NotificationMessage) MessageConversationPriority(org.hisp.dhis.message.MessageConversationPriority) DefaultPeriodService(org.hisp.dhis.period.DefaultPeriodService) DefaultValidationNotificationService(org.hisp.dhis.validation.notification.DefaultValidationNotificationService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MessageConversationPriority (org.hisp.dhis.message.MessageConversationPriority)1 NotificationMessage (org.hisp.dhis.notification.NotificationMessage)1 DefaultPeriodService (org.hisp.dhis.period.DefaultPeriodService)1 DefaultValidationNotificationService (org.hisp.dhis.validation.notification.DefaultValidationNotificationService)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1