use of cucumber.runtime.model.FeatureBuilder in project page-factory-2 by sbtqa.
the class GherkinSerializer method reserializeFeatures.
/**
* As soon as fragments are inserted, all features structure will unaligned by its file locations.
* So we need to realign it by reserializing features sources.
*
* @param cucumberFeatures unaligned features
* @return reserealized features
*/
public List<CucumberFeature> reserializeFeatures(List<CucumberFeature> cucumberFeatures) {
FeatureBuilder featureBuilder = new FeatureBuilder();
cucumberFeatures.forEach(cucumberFeature -> {
builder = new StringBuilder();
Feature feature = cucumberFeature.getGherkinFeature().getFeature();
builder.append("#language: ").append(feature.getLanguage());
nl(1);
if (!feature.getTags().isEmpty()) {
feature.getTags().forEach(tag -> builder.append(tag.getName()).append(SPACE));
nl(1);
}
builder.append(feature.getKeyword()).append(":").append(SPACE).append(feature.getName());
nl(1);
if (feature.getDescription() != null) {
tab(1);
builder.append(feature.getDescription());
nl(1);
}
nl(1);
feature.getChildren().forEach(scenarioDefinition -> buildScenario(builder, scenarioDefinition));
Resource gherkinResource = new GherkinResource(builder.toString(), cucumberFeature.getUri());
featureBuilder.parse(gherkinResource);
});
return featureBuilder.build();
}
Aggregations