Search in sources :

Example 26 with DomainMessage

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

the class SchedulerRestartJobService method sendJobRestartCanceled.

@IsSendingAsyncMessage(MessageID.JOB_RESTART_CANCELED)
private void sendJobRestartCanceled(JobDataContext context) {
    DomainMessage request = DomainMessageFactory.createEmptyRequest(MessageID.JOB_RESTART_CANCELED);
    JobMessage message = new JobMessage();
    message.setJobUUID(context.sechubJobUUID);
    message.setProjectId(context.projectId);
    message.setOwner(context.owner);
    message.setOwnerEmailAddress(context.ownerEmailAddress);
    message.setInfo(context.info);
    request.set(MessageDataKeys.JOB_RESTART_DATA, message);
    request.set(MessageDataKeys.ENVIRONMENT_BASE_URL, sechubEnvironment.getServerBaseUrl());
    eventBus.sendAsynchron(request);
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 27 with DomainMessage

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

the class SchedulerRestartJobService method sendJobRestartTriggered.

@IsSendingAsyncMessage(MessageID.JOB_RESTART_TRIGGERED)
private void sendJobRestartTriggered(ScheduleSecHubJob secHubJob, String ownerEmailAddress) {
    DomainMessage request = DomainMessageFactory.createEmptyRequest(MessageID.JOB_RESTART_TRIGGERED);
    JobMessage message = new JobMessage();
    message.setJobUUID(secHubJob.getUUID());
    message.setProjectId(secHubJob.getProjectId());
    message.setOwner(secHubJob.getOwner());
    message.setOwnerEmailAddress(ownerEmailAddress);
    request.set(MessageDataKeys.JOB_RESTART_DATA, message);
    request.set(MessageDataKeys.ENVIRONMENT_BASE_URL, sechubEnvironment.getServerBaseUrl());
    eventBus.sendAsynchron(request);
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 28 with DomainMessage

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

the class SchedulerRestartJobService method sendPurgeJobResultsSynchronousRequest.

@IsSendingSyncMessage(MessageID.REQUEST_PURGE_JOB_RESULTS)
private void sendPurgeJobResultsSynchronousRequest(ScheduleSecHubJob secHubJob) {
    DomainMessage request = DomainMessageFactory.createEmptyRequest(MessageID.REQUEST_PURGE_JOB_RESULTS);
    request.set(MessageDataKeys.SECHUB_UUID, secHubJob.getUUID());
    request.set(MessageDataKeys.ENVIRONMENT_BASE_URL, sechubEnvironment.getServerBaseUrl());
    DomainMessageSynchronousResult result = eventBus.sendSynchron(request);
    if (result.hasFailed()) {
        throw new SecHubRuntimeException("Purge failed!");
    }
}
Also used : DomainMessageSynchronousResult(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult) SecHubRuntimeException(com.mercedesbenz.sechub.commons.model.SecHubRuntimeException) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingSyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingSyncMessage)

Example 29 with DomainMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage 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 30 with DomainMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage 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)

Aggregations

DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)69 IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)31 UserMessage (com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage)21 Test (org.junit.Test)18 Test (org.junit.jupiter.api.Test)13 ProjectMessage (com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage)10 DomainMessageSynchronousResult (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult)8 JobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage)6 AdministrationConfigMessage (com.mercedesbenz.sechub.sharedkernel.messaging.AdministrationConfigMessage)5 BatchJobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.BatchJobMessage)4 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)3 IsSendingSyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingSyncMessage)3 UUID (java.util.UUID)3 ScheduleSecHubJob (com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob)2 SecHubExecutionException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)2 SecHubRuntimeException (com.mercedesbenz.sechub.commons.model.SecHubRuntimeException)1 AdministrationAutoCleanupConfig (com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig)1 User (com.mercedesbenz.sechub.domain.administration.user.User)1 ScanMockData (com.mercedesbenz.sechub.domain.scan.project.ScanMockData)1 ScanProjectConfig (com.mercedesbenz.sechub.domain.scan.project.ScanProjectConfig)1