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