Search in sources :

Example 51 with DomainMessage

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

the class ScheduleJobLauncherService method sendJobStarted.

@IsSendingAsyncMessage(MessageID.JOB_STARTED)
private void sendJobStarted(String projectId, UUID jobUUID, String configuration, String owner) {
    DomainMessage request = new DomainMessage(MessageID.JOB_STARTED);
    JobMessage message = new JobMessage();
    message.setProjectId(projectId);
    message.setJobUUID(jobUUID);
    message.setConfiguration(configuration);
    message.setOwner(owner);
    message.setSince(LocalDateTime.now());
    request.set(MessageDataKeys.JOB_STARTED_DATA, message);
    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 52 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_deleteAllProjectAccessService_is_called.

@Test
void when_sending_message_id_PROJECT_DELETED_the_deleteAllProjectAccessService_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.deleteAllProjectAccessService).deleteAnyAccessDataForProject("projectId1");
}
Also used : ProjectMessage(com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 53 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_ACCESS_LEVEL_CHANGED_changeProjectAccessLevel_is_called.

@Test
void when_sending_message_id_PROJECT_ACCESS_LEVEL_CHANGED_changeProjectAccessLevel_is_called() {
    /* prepare */
    ProjectAccessLevel newAccessLevel = ProjectAccessLevel.NONE;
    ProjectAccessLevel formerAccessLevel = ProjectAccessLevel.READ_ONLY;
    DomainMessage request = new DomainMessage(MessageID.PROJECT_ACCESS_LEVEL_CHANGED);
    ProjectMessage content = new ProjectMessage();
    content.setProjectId("projectId1");
    content.setFormerAccessLevel(formerAccessLevel);
    content.setNewAccessLevel(newAccessLevel);
    request.set(MessageDataKeys.PROJECT_ACCESS_LEVEL_CHANGE_DATA, content);
    /* execute */
    simulateEventSend(request, messageHandlerToTest);
    /* test */
    verify(messageHandlerToTest.projectAccessLevelService).changeProjectAccessLevel("projectId1", newAccessLevel, formerAccessLevel);
}
Also used : ProjectMessage(com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage) ProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 54 with DomainMessage

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

the class ScanServiceTest method event_handling_works_as_expected_and_SCAN_DONE_is_returned_as_resulting_message_id.

@Test
public void event_handling_works_as_expected_and_SCAN_DONE_is_returned_as_resulting_message_id() {
    /* prepare */
    DomainMessage request = prepareValidRequest();
    /* execute */
    DomainMessageSynchronousResult result = simulateEventSend(request, serviceToTest);
    /* test */
    assertEquals(MessageID.SCAN_DONE, result.getMessageId());
}
Also used : DomainMessageSynchronousResult(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

Example 55 with DomainMessage

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

the class ScanServiceTest method scan_service_fetches_mock_configuration_and_puts_mock_project_configuration_complete_in_execution_context.

@Test
public void scan_service_fetches_mock_configuration_and_puts_mock_project_configuration_complete_in_execution_context() throws Exception {
    /* prepare */
    SecHubConfiguration configNoProjectId = prepareValidConfiguration();
    DomainMessage request = prepareRequest(configNoProjectId);
    ScanProjectMockDataConfiguration projectMockDataConfig = new ScanProjectMockDataConfiguration();
    projectMockDataConfig.setCodeScan(new ScanMockData(TrafficLight.YELLOW));
    ScanProjectConfig projectConfig = new ScanProjectConfig(ScanProjectConfigID.MOCK_CONFIGURATION, TEST_PROJECT_ID1);
    projectConfig.setData(projectMockDataConfig.toJSON());
    when(scanProjectConfigService.get("test-project-id1", ScanProjectConfigID.MOCK_CONFIGURATION, false)).thenReturn(projectConfig);
    /* execute */
    simulateEventSend(request, serviceToTest);
    /* test */
    ArgumentCaptor<SecHubExecutionContext> contextCaptor = ArgumentCaptor.forClass(SecHubExecutionContext.class);
    verify(codeScanProductExecutionService).executeProductsAndStoreResults(contextCaptor.capture());
    SecHubExecutionContext context = contextCaptor.getValue();
    assertEquals(projectMockDataConfig, context.getData(ScanKey.PROJECT_MOCKDATA_CONFIGURATION));
}
Also used : SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ScanMockData(com.mercedesbenz.sechub.domain.scan.project.ScanMockData) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) ScanProjectConfig(com.mercedesbenz.sechub.domain.scan.project.ScanProjectConfig) ScanProjectMockDataConfiguration(com.mercedesbenz.sechub.domain.scan.project.ScanProjectMockDataConfiguration) 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