Search in sources :

Example 36 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class SignUpRequestedAdminNotificationServiceTest method sends_email_to_admins_containing_userid_and_email_from_event.

@Test
public void sends_email_to_admins_containing_userid_and_email_from_event() throws Exception {
    /* prepare */
    when(mockedNotificationConfiguration.getEmailAdministrators()).thenReturn("adminMail");
    SimpleMailMessage mockedMailMessage = mock(SimpleMailMessage.class);
    when(mockedMailMessageFactory.createMessage(any())).thenReturn(mockedMailMessage);
    // message to receive from event bus
    UserMessage message = mock(UserMessage.class);
    when(message.getUserId()).thenReturn("schlaubi");
    when(message.getEmailAdress()).thenReturn("schlau.schlumpf@schlumpfhausen.de");
    /* execute */
    serviceToTest.notify(message);
    /* test */
    // check mocked mail message was sent
    ArgumentCaptor<SimpleMailMessage> mailMessageCaptor = ArgumentCaptor.forClass(SimpleMailMessage.class);
    verify(mockedEmailService).send(mailMessageCaptor.capture());
    assertSame(mockedMailMessage, mailMessageCaptor.getValue());
    verify(mockedMailMessage).setTo("adminMail");
    // check content
    ArgumentCaptor<String> stringMessageCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockedMailMessage).setText(stringMessageCaptor.capture());
    String textInMessageBody = stringMessageCaptor.getValue();
    assertTrue(textInMessageBody.contains("schlaubi"));
    assertTrue(textInMessageBody.contains("schlau.schlumpf@schlumpfhausen.de"));
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) Test(org.junit.Test)

Example 37 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class ScanMessageHandler method handleUserRemovedFromProject.

@IsReceivingAsyncMessage(MessageID.USER_REMOVED_FROM_PROJECT)
private void handleUserRemovedFromProject(DomainMessage request) {
    UserMessage data = request.get(MessageDataKeys.PROJECT_TO_USER_DATA);
    revokeUserFromProjectService.revokeUserAccessFromProject(data.getUserId(), data.getProjectId());
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Example 38 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class ScanMessageHandler method handleUserDeleted.

@IsReceivingAsyncMessage(MessageID.USER_DELETED)
private void handleUserDeleted(DomainMessage request) {
    UserMessage data = request.get(MessageDataKeys.USER_DELETE_DATA);
    revokeUserService.revokeUserAccess(data.getUserId());
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Aggregations

UserMessage (com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage)38 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)21 IsReceivingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)11 IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)10 Test (org.junit.Test)8 Test (org.junit.jupiter.api.Test)5 NotAcceptableException (com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException)2 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Validated (org.springframework.validation.annotation.Validated)2 UseCaseAdminDeletesUser (com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminDeletesUser)1 UseCaseAdminUpdatesUserEmailAddress (com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUpdatesUserEmailAddress)1