public void startProcessing(Job job, Thread thread) {
        Optional<Job> optionalExistingThatMayBeReplacedJob = jobsCurrentlyInProgress.keySet().stream().filter(j -> j.getId().equals(job.getId())).findFirst();
        optionalExistingThatMayBeReplacedJob
                .map(j -> j.delete("Job has been replaced"))
                .map(jobsCurrentlyInProgress::get)
                .ifPresent(Thread::interrupt);
        jobsCurrentlyInProgress.put(job, thread);
    }
@Test
    void jobsThatAreProcessedAreBeingUpdatedWithAHeartbeat() {
        jobSteward = initializeBackgroundJobServerWithJobSteward();

        final Job job = anEnqueuedJob().withId().build();
        job.startProcessingOn(backgroundJobServer);
        jobSteward.startProcessing(job, mock(Thread.class));
        jobSteward.run();

        verify(storageProvider).save(singletonList(job));
        ProcessingState processingState = job.getJobState();
        assertThat(processingState.getUpdatedAt()).isAfter(processingState.getCreatedAt());
    }