BasicSection implements Section { @Override public Stream<Feature> getFeatures() { return Stream.concat( hasRoot() ? root.getFeatures() : Stream.empty(), getChildren().flatMap(Section::getFeatures)); } BasicSection(String id);  BasicSection(String id, String style);  BasicSection(String id, String style, String groupingTagPattern); @Override Section addFeature(Feature feature); @Override String render(CukedoctorDocumentBuilder docBuilder, I18nLoader i18n, DocumentAttributes documentAttributes); @Override int getOrder(); @Override Stream<Feature> getFeatures();  }
@Test public void shouldGetNoFeaturesIfEmpty() { final BasicSection section = createSection(); assertThat(section.getFeatures()).isEmpty(); }
@Test public void shouldGetFeaturesInOrder() { final Feature one = FeatureBuilder.instance().tag("@order-1").scenario(ScenarioBuilder.instance().name("Root").build()).build(); final Feature two = FeatureBuilder.instance().tag("order-2").build(); final Feature three = FeatureBuilder.instance().tag("order-3").tag("@group-one").scenario(ScenarioBuilder.instance().name("Root").build()).build(); final Feature four = FeatureBuilder.instance().tag("order-4").tag("@group-one").build(); final Feature five = FeatureBuilder.instance().tag("order-5").build(); final BasicSection section = new BasicSection("My Section", null, "@group-"); section.addFeatures(Arrays.asList(five, three, four, one, two)); assertThat(section.getFeatures()).containsExactly(one, two, three, four, five); }