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));
}
Aggregations