Search in sources :

Example 1 with ClusterMemberMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.ClusterMemberMessage 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());
}
Also used : ArrayList(java.util.ArrayList) ClusterMemberMessage(com.mercedesbenz.sechub.sharedkernel.messaging.ClusterMemberMessage) ScheduleSecHubJob(com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob) UUID(java.util.UUID) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

Aggregations

ScheduleSecHubJob (com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob)1 ClusterMemberMessage (com.mercedesbenz.sechub.sharedkernel.messaging.ClusterMemberMessage)1 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 Test (org.junit.Test)1