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