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