Search in sources :

Example 31 with DomainMessage

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

Example 32 with DomainMessage

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

the class NotificationMessageHandlerTest method an_event_about_changed_api_token_triggers_newApiTokenUserNotificationService.

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

Example 33 with DomainMessage

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

the class ScanMessageHandlerTest method when_sending_message_id_PROJECT_DELETED_the_deleteAllDataForProject_is_called.

@Test
void when_sending_message_id_PROJECT_DELETED_the_deleteAllDataForProject_is_called() {
    /* prepare */
    DomainMessage request = new DomainMessage(MessageID.PROJECT_DELETED);
    ProjectMessage content = new ProjectMessage();
    content.setProjectId("projectId1");
    request.set(MessageDataKeys.PROJECT_DELETE_DATA, content);
    /* execute */
    simulateEventSend(request, messageHandlerToTest);
    /* test */
    verify(messageHandlerToTest.projectDataDeleteService).deleteAllDataForProject("projectId1");
}
Also used : ProjectMessage(com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 34 with DomainMessage

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

the class ScanMessageHandlerTest method handler_receiving_auto_cleanup_calls_config_sevice_with_message_data.

@Test
void handler_receiving_auto_cleanup_calls_config_sevice_with_message_data() {
    /* prepare */
    long days = System.nanoTime();
    AdministrationConfigMessage configMessage = new AdministrationConfigMessage();
    configMessage.setAutoCleanupInDays(days);
    DomainMessage message = new DomainMessage(MessageID.AUTO_CLEANUP_CONFIGURATION_CHANGED);
    message.set(MessageDataKeys.AUTO_CLEANUP_CONFIG_CHANGE_DATA, configMessage);
    /* execute */
    messageHandlerToTest.receiveAsyncMessage(message);
    /* test */
    verify(messageHandlerToTest.configService).updateAutoCleanupInDays(days);
}
Also used : AdministrationConfigMessage(com.mercedesbenz.sechub.sharedkernel.messaging.AdministrationConfigMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 35 with DomainMessage

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

the class ScanServiceTest method scanservice_does_cleanup_storage_of_job__when_HAS_failed.

/**
 * Here we test that on failure the storage is ALSO cleaned. Why? Because in
 * future there should be the possiblity for a retry mechanism, but currently
 * there is none. When this is implemented we must change the test so it will
 * check there is NO cleaning. But having no retry mechanism implemented, we
 * expect the cleanup process done even when failing.
 *
 * @throws Exception
 */
@Test
public void scanservice_does_cleanup_storage_of_job__when_HAS_failed() throws Exception {
    /* prepare */
    DomainMessage request = prepareValidRequest();
    doThrow(new SecHubExecutionException("ups...", new RuntimeException())).when(webScanProductExecutionService).executeProductsAndStoreResults(any());
    /* execute */
    DomainMessageSynchronousResult result = serviceToTest.receiveSynchronMessage(request);
    /* test */
    assertTrue(result.hasFailed());
    verify(jobStorage).deleteAll();
}
Also used : SecHubExecutionException(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException) DomainMessageSynchronousResult(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult) 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