public void execute() { Collection<PostJobWrapper> postJobs = selector.selectPostJobs(); execute(postJobs); }
public Collection<PostJobWrapper> selectPostJobs() { Collection<PostJob> result = sort(getFilteredExtensions(PostJob.class, null)); return result.stream() .map(j -> new PostJobWrapper(j, postJobContext, postJobOptimizer)) .filter(PostJobWrapper::shouldExecute) .collect(Collectors.toList()); } }
private PostJobExtensionDictionnary newSelector(Object... extensions) { ComponentContainer iocContainer = new ComponentContainer(); for (Object extension : extensions) { iocContainer.addSingleton(extension); } return new PostJobExtensionDictionnary(iocContainer, postJobOptimizer, mock(PostJobContext.class)); }
@Test public void should_execute_post_jobs() { when(selector.selectPostJobs()).thenReturn(Arrays.asList(job1, job2)); when(job1.shouldExecute()).thenReturn(true); executor.execute(); verify(job1).shouldExecute(); verify(job2).shouldExecute(); verify(job1).execute(); verifyNoMoreInteractions(job1, job2); } }
public Collection<PostJobWrapper> selectPostJobs() { Collection<PostJob> result = sort(getFilteredExtensions(PostJob.class, null)); return result.stream() .map(j -> new PostJobWrapper(j, postJobContext, postJobOptimizer)) .filter(PostJobWrapper::shouldExecute) .collect(Collectors.toList()); } }
@Test public void dependsUponPhaseForPostJob() { PrePostJob pre = new PrePostJob(); NormalPostJob normal = new NormalPostJob(); PostJobExtensionDictionnary selector = newSelector(normal, pre); assertThat(selector.selectPostJobs()).extracting("wrappedPostJob").containsExactly(pre, normal); }
public void execute() { Collection<PostJobWrapper> postJobs = selector.selectPostJobs(); execute(postJobs); }