CustomProcessorsCollector { public LinkedList<FieldPostProcessor> getHighPriorityFieldPostProcessors() { LinkedList<FieldPostProcessor> result = new LinkedList<FieldPostProcessor>(); result.addAll(sortAndGetPositivePostProcessors(toList(priorityCustomFieldPostProcessors))); result.addAll(toList(customFieldPostProcessors)); return result; }  LinkedList<FieldProcessor> getFieldProcessors(); LinkedList<FieldPostProcessor> getHighPriorityFieldPostProcessors(); LinkedList<FieldPostProcessor> getLowPriorityFieldPostProcessors();  }
@Test public void getHighPriorityFieldPostProcessors_noCustomProcessors_returnsEmptyList() throws Exception { noProcessors(); LinkedList<FieldPostProcessor> actualResult = testedObject.getHighPriorityFieldPostProcessors(); assertThat(actualResult).isEmpty(); }
@Test public void getHighPriorityFieldPostProcessors_customProcessorsSet_priorityProcessorsTakePrecedenceOverNonRpriorityProcessors() throws Exception { FieldPostProcessor nonPriorityProcessor = stubPostProcessor(); PriorityFieldPostProcessor priorityProcessor = stubPriorityPostProcessor(0); setPostProcessors(nonPriorityProcessor); setPriorityPostProcessors(priorityProcessor); LinkedList<FieldPostProcessor> expectedResult = asList(priorityProcessor, nonPriorityProcessor); LinkedList<FieldPostProcessor> actualResult = testedObject.getHighPriorityFieldPostProcessors(); assertThat(actualResult).isEqualTo(expectedResult); }
@Test public void getHighPriorityFieldPostProcessors_multipleHighAndLowPriorityProcessors_returnsListOfHighPriorityProcessorsOnlySortedAccordingToPriority() throws Exception { PriorityFieldPostProcessor lowPriorityProcessor = stubPriorityPostProcessor(-1); PriorityFieldPostProcessor defaultPriorityProcessor = stubPriorityPostProcessor(0); PriorityFieldPostProcessor highPriorityProcessor = stubPriorityPostProcessor(1); setPriorityPostProcessors(lowPriorityProcessor, defaultPriorityProcessor, highPriorityProcessor); LinkedList<FieldPostProcessor> expectedResult = asList(highPriorityProcessor, defaultPriorityProcessor); LinkedList<FieldPostProcessor> actualResult = testedObject.getHighPriorityFieldPostProcessors(); assertThat(actualResult).isEqualTo(expectedResult); }