@Override
    public void resolve(ConcurrentJobModificationException e) {
        final List<Job> concurrentUpdatedJobs = e.getConcurrentUpdatedJobs();
        final List<ConcurrentJobModificationResolveResult> failedToResolve = concurrentUpdatedJobs
                .stream()
                .map(this::resolve)
                .filter(ConcurrentJobModificationResolveResult::failed)
                .collect(toList());

        if (!failedToResolve.isEmpty()) {
            throw new UnresolvableConcurrentJobModificationException(failedToResolve, e);
        }
    }
@Test
    void concurrentStateChangeFromProcessingToDeletedIsAllowedAndInterruptsThread() {
        final Job job1 = aJobInProgress().build();
        final Job job2 = aJobInProgress().build();

        final Thread job1Thread = mock(Thread.class);
        final Thread job2Thread = mock(Thread.class);

        when(storageProvider.getJobById(job1.getId())).thenReturn(aCopyOf(job1).withDeletedState().build());
        when(storageProvider.getJobById(job2.getId())).thenReturn(aCopyOf(job2).withDeletedState().build());

        when(jobSteward.getThreadProcessingJob(job1)).thenReturn(job1Thread);
        when(jobSteward.getThreadProcessingJob(job2)).thenReturn(job2Thread);

        concurrentJobModificationResolver.resolve(new ConcurrentJobModificationException(asList(job1, job2)));

        verify(job1Thread).interrupt();
        verify(job2Thread).interrupt();
        assertThat(job1).hasState(DELETED);
        assertThat(job2).hasState(DELETED);
    }