Search in sources :

Example 36 with DomainMessage

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

the class ScanServiceTest method scanservice_does_NOT_execute_reportservice_when_webscan_throws_sechubexception.

@Test
public void scanservice_does_NOT_execute_reportservice_when_webscan_throws_sechubexception() 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(webScanProductExecutionService).executeProductsAndStoreResults(any());
    verify(reportService, never()).createReport(any());
}
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)

Example 37 with DomainMessage

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

the class ScanServiceTest method event_handling_FAILED_when_configuration_is_set_but_contains_no_projectId.

@Test
public void event_handling_FAILED_when_configuration_is_set_but_contains_no_projectId() {
    /* prepare */
    SecHubConfiguration configNoProjectId = prepareValidConfiguration();
    configNoProjectId.setProjectId(null);
    DomainMessage request = prepareRequest(configNoProjectId);
    /* execute */
    DomainMessageSynchronousResult result = simulateEventSend(request, serviceToTest);
    /* test */
    assertEquals(MessageID.SCAN_FAILED, result.getMessageId());
}
Also used : DomainMessageSynchronousResult(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

Example 38 with DomainMessage

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

the class ScanServiceTest method prepareRequest.

private DomainMessage prepareRequest(SecHubConfiguration configMin) {
    DomainMessage request = new DomainMessage(MessageID.START_SCAN);
    request.set(MessageDataKeys.SECHUB_UUID, UUID);
    request.set(MessageDataKeys.SECHUB_CONFIG, configMin);
    BatchJobMessage batchJobMessage = new BatchJobMessage();
    batchJobMessage.setSecHubJobUUID(UUID);
    batchJobMessage.setBatchJobId(42);
    request.set(MessageDataKeys.BATCH_JOB_ID, batchJobMessage);
    return request;
}
Also used : BatchJobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.BatchJobMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)

Example 39 with DomainMessage

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

the class ProductResultService method sendJobResultsPurged.

@IsSendingAsyncMessage(MessageID.JOB_RESULTS_PURGED)
private void sendJobResultsPurged(UUID jobUUID) {
    DomainMessage request = DomainMessageFactory.createEmptyRequest(MessageID.JOB_RESULTS_PURGED);
    request.set(MessageDataKeys.SECHUB_UUID, jobUUID);
    request.set(MessageDataKeys.ENVIRONMENT_BASE_URL, sechubEnvironment.getServerBaseUrl());
    eventBus.sendAsynchron(request);
}
Also used : DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 40 with DomainMessage

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

the class ScheduleMessageHandlerTest 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, scheduleHandlerToTest);
    /* test */
    verify(scheduleHandlerToTest.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)

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