CustomProcessorsCollector { public LinkedList<FieldProcessor> getFieldProcessors() { LinkedList<FieldProcessor> result = new LinkedList<FieldProcessor>(); result.addAll(sortByPriority(toList(priorityCustomFieldProcessors))); result.addAll(toList(customFieldProcessors)); return result; }  LinkedList<FieldProcessor> getFieldProcessors(); LinkedList<FieldPostProcessor> getHighPriorityFieldPostProcessors(); LinkedList<FieldPostProcessor> getLowPriorityFieldPostProcessors();  }
@Test public void getFieldProcessors_noCustomProcessors_returnsEmptyList() throws Exception { noProcessors(); LinkedList<FieldProcessor> actualResult = testedObject.getFieldProcessors(); assertThat(actualResult).isEmpty(); }
@Test public void getFieldProcessors_customProcessorsSet_priorityProcessorsTakePrecedenceOverNonRpriorityProcessors() throws Exception { FieldProcessor nonPriorityProcessor = stubProcessor(); PriorityFieldProcessor priorityProcessor = stubPriorityProcessor(0); setProcessors(nonPriorityProcessor); setPriorityProcessors(priorityProcessor); LinkedList<FieldProcessor> expectedResult = asList(priorityProcessor, nonPriorityProcessor); LinkedList<FieldProcessor> actualResult = testedObject.getFieldProcessors(); assertThat(actualResult).isEqualTo(expectedResult); }
@Test public void getFieldProcessors_multiplePriorityProcessors_returnsListSortedAccordingToPriority() throws Exception { PriorityFieldProcessor lowPriorityProcessor = stubPriorityProcessor(-1); PriorityFieldProcessor defaultPriorityProcessor = stubPriorityProcessor(0); PriorityFieldProcessor highPriorityProcessor = stubPriorityProcessor(1); setPriorityProcessors(lowPriorityProcessor, defaultPriorityProcessor, highPriorityProcessor); LinkedList<FieldProcessor> expectedResult = asList(highPriorityProcessor, defaultPriorityProcessor, lowPriorityProcessor); LinkedList<FieldProcessor> actualResult = testedObject.getFieldProcessors(); assertThat(actualResult).isEqualTo(expectedResult); }