use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class ScheduleMessageHandlerTest method when_sending_message_id_USER_ADDED_TO_PROJECT_the_addUserToProjectService_is_called.
@Test
void when_sending_message_id_USER_ADDED_TO_PROJECT_the_addUserToProjectService_is_called() {
/* prepare */
DomainMessage request = new DomainMessage(MessageID.USER_ADDED_TO_PROJECT);
UserMessage content = new UserMessage();
content.setProjectId("projectId1");
content.setUserId("userId1");
request.set(MessageDataKeys.PROJECT_TO_USER_DATA, content);
/* execute */
simulateEventSend(request, scheduleHandlerToTest);
/* test */
verify(scheduleHandlerToTest.grantService).grantUserAccessToProject("userId1", "projectId1");
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class SchedulerStartHandlerTest method schedulerHasBeenStarted.
@Test
public void schedulerHasBeenStarted() throws Exception {
/* prepare */
List<ScheduleSecHubJob> jobsRunningButStartedBefore = new ArrayList<>();
ScheduleSecHubJob job1 = mock(ScheduleSecHubJob.class);
UUID uuid1 = UUID.randomUUID();
when(job1.getUUID()).thenReturn(uuid1);
jobsRunningButStartedBefore.add(job1);
when(repository.findAllRunningJobsStartedBefore(any())).thenReturn(jobsRunningButStartedBefore);
/* execute */
handlerToTest.schedulerHasBeenStarted().run();
/* test */
ArgumentCaptor<DomainMessage> argument = ArgumentCaptor.forClass(DomainMessage.class);
verify(eventBus).sendAsynchron(argument.capture());
DomainMessage domainMessage = argument.getValue();
assertEquals(BASE_URL1, domainMessage.get(MessageDataKeys.ENVIRONMENT_BASE_URL));
ClusterMemberMessage status = domainMessage.get(MessageDataKeys.ENVIRONMENT_CLUSTER_MEMBER_STATUS);
assertNotNull(status);
assertEquals(HOSTNAME_1, status.getHostName());
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class ScanExecutionTasklet method sendJobInfo.
private void sendJobInfo(MessageDataKey<JobMessage> key, UUID jobUUID, MessageID id) {
DomainMessage request = new DomainMessage(id);
JobMessage message = createMessage(jobUUID);
request.set(key, message);
scope.getEventBusService().sendAsynchron(request);
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class SchedulerConfigService method setJobProcessingEnabled.
/**
* Enables or disables job processing
*
* @param enableJobProcessing
* @return <code>true</code> when processing has been changed and a event was
* sent. <code>false</code> when already in wanted state
*/
boolean setJobProcessingEnabled(boolean enableJobProcessing) {
SchedulerConfig config = getOrCreateConfig();
if (enableJobProcessing == config.isJobProcessingEnabled()) {
return false;
}
config.setJobProcessingEnabled(enableJobProcessing);
repository.save(config);
DomainMessage domainMessage = null;
if (enableJobProcessing) {
domainMessage = DomainMessageFactory.createEmptyRequest(MessageID.SCHEDULER_JOB_PROCESSING_ENABLED);
} else {
domainMessage = DomainMessageFactory.createEmptyRequest(MessageID.SCHEDULER_JOB_PROCESSING_DISABLED);
}
domainMessage.set(MessageDataKeys.ENVIRONMENT_BASE_URL, environmentData.getServerBaseUrl());
domainMessageService.sendAsynchron(domainMessage);
return true;
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage in project sechub by mercedes-benz.
the class SchedulerStatusService method buildStatus.
@IsSendingAsyncMessage(MessageID.SCHEDULER_STATUS_UPDATE)
public void buildStatus() {
DomainMessage message = DomainMessageFactory.createEmptyRequest(MessageID.SCHEDULER_STATUS_UPDATE);
SchedulerMessage sm = new SchedulerMessage();
long amountOfJobsAll = jobRepository.count();
long amountOfRunningJobs = jobRepository.countRunningJobs();
long amountOfWaitingJobs = jobRepository.countWaitingJobs();
boolean processingEnabled = configService.isJobProcessingEnabled();
sm.setAmountOfJobsAll(amountOfJobsAll);
sm.setAmountOfRunningJobs(amountOfRunningJobs);
sm.setAmountOfWaitingJobs(amountOfWaitingJobs);
sm.setJobProcessingEnabled(processingEnabled);
message.set(MessageDataKeys.SCHEDULER_STATUS_DATA, sm);
eventBus.sendAsynchron(message);
}
Aggregations