Search in sources :

Example 16 with UserMessage

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

the class AuthMessageHandler method handleUserRolesChanged.

@IsReceivingAsyncMessage(MessageID.USER_ROLES_CHANGED)
private void handleUserRolesChanged(DomainMessage request) {
    UserMessage userMessage = request.get(MessageDataKeys.USER_ROLES_DATA);
    userAuthUpdateRolesService.updateRoles(userMessage.getUserId(), userMessage.getRoles());
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Example 17 with UserMessage

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

the class AuthMessageHandler method handleUserDeleted.

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

Example 18 with UserMessage

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

the class UserEmailAddressUpdateServiceTest method sends_event_with_user_data_when_parameters_are_valid.

@Test
void sends_event_with_user_data_when_parameters_are_valid() {
    /* prepare */
    User knownUser1 = createKnownUser1();
    when(userRepository.findOrFailUser(KNOWN_USER1)).thenReturn(knownUser1);
    /* execute */
    serviceToTest.updateUserEmailAddress(KNOWN_USER1, "new.user1@example.com");
    /* test */
    // check event is sent with expected data
    ArgumentCaptor<DomainMessage> messageCaptor = ArgumentCaptor.forClass(DomainMessage.class);
    verify(eventBusService).sendAsynchron(messageCaptor.capture());
    UserMessage userMessage = messageCaptor.getValue().get(MessageDataKeys.USER_EMAIL_ADDRESS_CHANGE_DATA);
    assertNotNull(userMessage);
    assertEquals(KNOWN_USER1, userMessage.getUserId());
    assertEquals("new.user1@example.com", userMessage.getEmailAdress());
    assertEquals("former.user1@example.com", userMessage.getFormerEmailAddress());
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 19 with UserMessage

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

the class NotificationMessageHandlerTest method an_event_about_deleted_user_triggers_UserDeletedNotificationService.

@Test
public void an_event_about_deleted_user_triggers_UserDeletedNotificationService() {
    /* prepare */
    UserMessage userMessage = mock(UserMessage.class);
    DomainMessage request = mock(DomainMessage.class);
    when(request.getMessageId()).thenReturn(MessageID.USER_DELETED);
    when(request.get(MessageDataKeys.USER_DELETE_DATA)).thenReturn(userMessage);
    /* execute */
    handlerToTest.receiveAsyncMessage(request);
    /* test */
    verify(mockedUserDeletedNotificationService).notify(userMessage);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

Example 20 with UserMessage

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

the class NotificationMessageHandlerTest method an_event_about_created_signup_triggers_signUpCreatedAdminNotificationService_with_included_signup_data.

@Test
public void an_event_about_created_signup_triggers_signUpCreatedAdminNotificationService_with_included_signup_data() {
    /* prepare */
    UserMessage userMessage = mock(UserMessage.class);
    DomainMessage request = mock(DomainMessage.class);
    when(request.getMessageId()).thenReturn(MessageID.USER_SIGNUP_REQUESTED);
    when(request.get(MessageDataKeys.USER_SIGNUP_DATA)).thenReturn(userMessage);
    /* execute */
    handlerToTest.receiveAsyncMessage(request);
    /* test */
    verify(mockedSignUpRequestedAdminNotificationService).notify(userMessage);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

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