@Test public void shouldRenderSummaryInOrder() { final Feature one = FeatureBuilder.instance().name("one").keyword("Feature").tag("@order-1").tag("@section-one").scenario(ScenarioBuilder.instance().name("Root").build()).build(); final Feature two = FeatureBuilder.instance().name("two").keyword("Feature").tag("order-2").tag("@section-two").tag("@subsection-one").scenario(ScenarioBuilder.instance().name("Root").build()).build(); final Feature three = FeatureBuilder.instance().name("three").keyword("Feature").tag("order-3").tag("@section-two").tag("@subsection-one").scenario(ScenarioBuilder.instance().name("Fake").build()).build(); final Feature four = FeatureBuilder.instance().name("four").keyword("Feature").tag("order-4").tag("@section-three").scenario(ScenarioBuilder.instance().name("Fake").build()).build(); final Feature five = FeatureBuilder.instance().name("five").keyword("Feature").tag("order-5").scenario(ScenarioBuilder.instance().name("Fake").build()).build(); final Feature six = FeatureBuilder.instance().name("six").keyword("Feature").tag("order-6").tag("@subsection-one").scenario(ScenarioBuilder.instance().name("Fake").build()).build(); final Feature seven = FeatureBuilder.instance().name("seven").keyword("Feature").tag("order-7").tag("@appendix").tag("@section-four").tag("@subsection-one").scenario(ScenarioBuilder.instance().name("Root").build()).build(); final Feature eight = FeatureBuilder.instance().name("eight").keyword("Feature").tag("order-8").tag("@appendix").tag("@section-five").scenario(ScenarioBuilder.instance().name("Fake").build()).build(); SummaryRenderer underlyingRenderer = mock(SummaryRenderer.class); when(underlyingRenderer.renderSummary(any(List.class), any(CukedoctorDocumentBuilder.class))).thenReturn("My Summary"); final SectionSummaryRenderer renderer = new SectionSummaryRenderer(new ServiceLoaderUtil<SummaryRenderer>(Collections.singletonList(underlyingRenderer))); String result = renderer.renderSummary(Arrays.asList(six, five, three, four, one, two, seven, eight), CukedoctorDocumentBuilder.Factory.newInstance()); assertEquals("My Summary", result); ArgumentCaptor<List> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(underlyingRenderer).renderSummary(argumentCaptor.<List<Feature>>capture(), any(CukedoctorDocumentBuilder.class)); List<Feature> features = argumentCaptor.<List<Feature>>getValue(); assertThat(features).containsExactly(one, two, three, four, five, six, seven, eight); }
@Override public String renderSummary(List<Feature> features) { return renderer.get().renderSummary(getSortedFeatures(features), docBuilder); }
SectionSummaryRenderer extends AbstractBaseRenderer implements SummaryRenderer { @Override public String renderSummary(List<Feature> features) { return renderer.get().renderSummary(getSortedFeatures(features), docBuilder); } }
SectionSummaryRenderer extends AbstractBaseRenderer implements SummaryRenderer { @Override public String renderSummary(List<Feature> features) { return renderer.get().renderSummary(getSortedFeatures(features), docBuilder); } SectionSummaryRenderer();  SectionSummaryRenderer(ServiceLoaderUtil<SummaryRenderer> loader); }
SectionSummaryRenderer extends AbstractBaseRenderer implements SummaryRenderer { @Override public String renderSummary(List<Feature> features) { return renderer.get().renderSummary(getSortedFeatures(features), docBuilder); } SectionSummaryRenderer();  SectionSummaryRenderer(ServiceLoaderUtil<SummaryRenderer> loader); @Override String renderSummary(List<Feature> features); @Override void setI18n(I18nLoader i18n); @Override void setDocumentBuilder(CukedoctorDocumentBuilder documentBuilder); @Override void setDocumentAttributes(DocumentAttributes documentAttributes); }
SectionSummaryRenderer extends AbstractBaseRenderer implements SummaryRenderer { @Override public String renderSummary(List<Feature> features) { return renderer.get().renderSummary(getSortedFeatures(features), docBuilder); } SectionSummaryRenderer();  SectionSummaryRenderer(ServiceLoaderUtil<SummaryRenderer> loader); @Override String renderSummary(List<Feature> features); @Override void setI18n(I18nLoader i18n); @Override void setDocumentBuilder(CukedoctorDocumentBuilder documentBuilder); @Override void setDocumentAttributes(DocumentAttributes documentAttributes);  }