@Test public void shouldRenderAppendicesInOrderAfterFeaturesSection() { DocumentSection root = new DocumentSection(); root.addFeature(FeatureBuilder.instance().id("Amazing Feature").name("Amazing Feature").tag("@section-Beta").tag("@order-4").build()); root.addFeature(FeatureBuilder.instance().id("My Feature").name("My Feature").tag("@section-Beta").tag("@order-3").tag("@appendix").build()); root.addFeature(FeatureBuilder.instance().id("Yet Another Feature").name("Yet Another Feature").tag("@section-Alpha").tag("@order-1").tag("@appendix").build()); root.addFeature(FeatureBuilder.instance().id("Alpha: The Beginning").name("Alpha: The Beginning").tag("@section-Alpha").tag("@order-2").tag("@appendix").scenario(ScenarioBuilder.instance().name("Root").build()).build()); root.addFeature(FeatureBuilder.instance().id("Exciting Feature").name("Exciting Feature").build()); final String expectedDocument = "[[Features, Features]]" + newLine() + "= *Features*" + newLine() + newLine() + newLine() + "[[Exciting-Feature, Exciting Feature]]" + newLine() + "== *Exciting Feature*" + newLine() + newLine() + "[appendix]" + newLine() + "[[Alpha:-The-Beginning, Alpha: The Beginning]]" + newLine() + "= *Alpha: The Beginning*" + newLine() + newLine() + newLine() + "[[Yet-Another-Feature, Yet Another Feature]]" + newLine() + "== *Yet Another Feature*" + newLine() + newLine() + "[appendix]" + newLine() + "[[Beta, Beta]]" + newLine() + "= *Beta*" + newLine() + newLine() + newLine() + "[[My-Feature, My Feature]]" + newLine() + "== *My Feature*" + newLine() + newLine() + "[[Amazing-Feature, Amazing Feature]]" + newLine() + "== *Amazing Feature*" + newLine() + newLine(); assertEquals(expectedDocument, renderDocument(root)); }
@Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } DocumentSection();  DocumentSection(Iterable<Feature> features); }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } DocumentSection();  DocumentSection(Iterable<Feature> features); @Override Section addFeature(Feature feature); @Override String render(CukedoctorDocumentBuilder docBuilder, I18nLoader i18n, DocumentAttributes documentAttributes); @Override int getOrder(); @Override Stream<Feature> getFeatures(); }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } DocumentSection();  DocumentSection(Iterable<Feature> features); @Override Section addFeature(Feature feature); @Override String render(CukedoctorDocumentBuilder docBuilder, I18nLoader i18n, DocumentAttributes documentAttributes); @Override int getOrder(); @Override Stream<Feature> getFeatures();  }