@Test public void buildZombieInformation_zombiesFound_infomrmation_with_job_UUID_is_contained() { List<ScheduleSecHubJob> jobsRunningButStartedBefore = new ArrayList<>(); ScheduleSecHubJob job1 = mock(ScheduleSecHubJob.class); ScheduleSecHubJob job2 = mock(ScheduleSecHubJob.class); UUID uuid1 = UUID.randomUUID(); UUID uuid2 = UUID.randomUUID(); when(job1.getUUID()).thenReturn(uuid1); when(job2.getUUID()).thenReturn(uuid2); jobsRunningButStartedBefore.add(job1); jobsRunningButStartedBefore.add(job2); String result = handlerToTest.buildZombieInformation(jobsRunningButStartedBefore); assertTrue(result.contains("ATTENTION: Potential zombie jobs found")); assertTrue(result.contains(uuid1.toString())); assertTrue(result.contains(uuid2.toString())); }
String buildZombieInformation(List<ScheduleSecHubJob> jobsRunningButStartedBefore) { if (jobsRunningButStartedBefore == null || jobsRunningButStartedBefore.isEmpty()) { return "OK: No zombie jobs found"; } StringBuilder sb = new StringBuilder(); sb.append("---------------------------------------\n"); sb.append("ATTENTION: Potential zombie jobs found:\n"); sb.append("---------------------------------------\n"); for (ScheduleSecHubJob potentialZombieJob : jobsRunningButStartedBefore) { sb.append("- job:").append(potentialZombieJob.getUUID()); sb.append(", started:").append(potentialZombieJob.getStarted()); sb.append(", execution-state:").append(potentialZombieJob.getExecutionState()); sb.append("\n"); } sb.append( "\nPlease check if they have been already started by another before started (and still running) scheduler instance. If identified as zombie job you have to restart the job!"); return sb.toString(); }
SchedulerStartHandler { String buildZombieInformation(List<ScheduleSecHubJob> jobsRunningButStartedBefore) { if (jobsRunningButStartedBefore == null || jobsRunningButStartedBefore.isEmpty()) { return "OK: No zombie jobs found"; } StringBuilder sb = new StringBuilder(); sb.append("---------------------------------------\n"); sb.append("ATTENTION: Potential zombie jobs found:\n"); sb.append("---------------------------------------\n"); for (ScheduleSecHubJob potentialZombieJob : jobsRunningButStartedBefore) { sb.append("- job:").append(potentialZombieJob.getUUID()); sb.append(", started:").append(potentialZombieJob.getStarted()); sb.append(", execution-state:").append(potentialZombieJob.getExecutionState()); sb.append("\n"); } sb.append( "\nPlease check if they have been already started by another before started (and still running) scheduler instance. If identified as zombie job you have to restart the job!"); return sb.toString(); } }
SchedulerStartHandler { String buildZombieInformation(List<ScheduleSecHubJob> jobsRunningButStartedBefore) { if (jobsRunningButStartedBefore == null || jobsRunningButStartedBefore.isEmpty()) { return "OK: No zombie jobs found"; } StringBuilder sb = new StringBuilder(); sb.append("---------------------------------------\n"); sb.append("ATTENTION: Potential zombie jobs found:\n"); sb.append("---------------------------------------\n"); for (ScheduleSecHubJob potentialZombieJob : jobsRunningButStartedBefore) { sb.append("- job:").append(potentialZombieJob.getUUID()); sb.append(", started:").append(potentialZombieJob.getStarted()); sb.append(", execution-state:").append(potentialZombieJob.getExecutionState()); sb.append("\n"); } sb.append( "\nPlease check if they have been already started by another before started (and still running) scheduler instance. If identified as zombie job you have to restart the job!"); return sb.toString(); }  }
SchedulerStartHandler { String buildZombieInformation(List<ScheduleSecHubJob> jobsRunningButStartedBefore) { if (jobsRunningButStartedBefore == null || jobsRunningButStartedBefore.isEmpty()) { return "OK: No zombie jobs found"; } StringBuilder sb = new StringBuilder(); sb.append("---------------------------------------\n"); sb.append("ATTENTION: Potential zombie jobs found:\n"); sb.append("---------------------------------------\n"); for (ScheduleSecHubJob potentialZombieJob : jobsRunningButStartedBefore) { sb.append("- job:").append(potentialZombieJob.getUUID()); sb.append(", started:").append(potentialZombieJob.getStarted()); sb.append(", execution-state:").append(potentialZombieJob.getExecutionState()); sb.append("\n"); } sb.append( "\nPlease check if they have been already started by another before started (and still running) scheduler instance. If identified as zombie job you have to restart the job!"); return sb.toString(); }  @Bean @Order(Ordered.HIGHEST_PRECEDENCE) // want this at the very beginning of scheduler start @IsSendingAsyncMessage(MessageID.SCHEDULER_STARTED) @UseCaseAdministratorReceivesNotificationAboutNewchedulerInstanceStart(@Step(number = 1, name = "send domain message that new scheduler instance has been started and information about potential zombie jobs")) CommandLineRunner schedulerHasBeenStarted(); }
SchedulerStartHandler { String buildZombieInformation(List<ScheduleSecHubJob> jobsRunningButStartedBefore) { if (jobsRunningButStartedBefore == null || jobsRunningButStartedBefore.isEmpty()) { return "OK: No zombie jobs found"; } StringBuilder sb = new StringBuilder(); sb.append("---------------------------------------\n"); sb.append("ATTENTION: Potential zombie jobs found:\n"); sb.append("---------------------------------------\n"); for (ScheduleSecHubJob potentialZombieJob : jobsRunningButStartedBefore) { sb.append("- job:").append(potentialZombieJob.getUUID()); sb.append(", started:").append(potentialZombieJob.getStarted()); sb.append(", execution-state:").append(potentialZombieJob.getExecutionState()); sb.append("\n"); } sb.append( "\nPlease check if they have been already started by another before started (and still running) scheduler instance. If identified as zombie job you have to restart the job!"); return sb.toString(); }  @Bean @Order(Ordered.HIGHEST_PRECEDENCE) // want this at the very beginning of scheduler start @IsSendingAsyncMessage(MessageID.SCHEDULER_STARTED) @UseCaseAdministratorReceivesNotificationAboutNewchedulerInstanceStart(@Step(number = 1, name = "send domain message that new scheduler instance has been started and information about potential zombie jobs")) CommandLineRunner schedulerHasBeenStarted();  }