Skip to content

Commit

Permalink
Collect tagged feature files and scenario counts
Browse files Browse the repository at this point in the history
Issue: TNG#54
Signed-off-by: Johannes Thorn <2544827+johthor@users.noreply.github.com>
  • Loading branch information
johthor committed Jan 23, 2024
1 parent 240daf5 commit b48c593
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.tngtech.jgiven.report.model.Tag;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -21,23 +22,26 @@
class AsciiDocReportModelVisitor extends ReportModelVisitor {

private final ReportBlockConverter blockConverter;
private final List<String> asciiDocBlocks;
private final ReportStatistics featureStatistics;
private final CasesTableCalculator tableCalculator;
private final List<String> asciiDocBlocks;
private final Map<String, Integer> featureTagIds;
private Map<String, Tag> featureTagMap;
private List<Tag> tagList;
private boolean scenarioHasDataTable;
private boolean scenarioHasMultipleCases;
private boolean skipCurrentCase;
private boolean caseIsUnsuccessful;
private String currentSectionTitle;
private boolean scenarioHasMultipleCases;
private boolean isFirstStepInCase;
private String currentSectionTitle;

public AsciiDocReportModelVisitor(final ReportBlockConverter blockConverter,
final ReportStatistics featureStatistics) {
this.blockConverter = blockConverter;
this.asciiDocBlocks = new ArrayList<>();
this.featureStatistics = featureStatistics;
this.tableCalculator = new CasesTableCalculator();
this.asciiDocBlocks = new ArrayList<>();
this.featureTagIds = new HashMap<>();
}

@Override
Expand All @@ -55,12 +59,14 @@ public void visit(final ReportModel reportModel) {

@Override
public void visit(final ScenarioModel scenarioModel) {
final List<Tag> tags = scenarioModel.getTagIds().stream()
scenarioModel.getTagIds().forEach(tagId -> featureTagIds.merge(tagId, 1, Integer::sum));

tagList = scenarioModel.getTagIds().stream()
.map(this.featureTagMap::get)
.collect(Collectors.toList());

String scenarioHeader = blockConverter.convertScenarioHeaderBlock(scenarioModel.getDescription(),
scenarioModel.getExecutionStatus(), scenarioModel.getDurationInNanos(), tags,
scenarioModel.getExecutionStatus(), scenarioModel.getDurationInNanos(), tagList,
scenarioModel.getExtendedDescription());
asciiDocBlocks.add(scenarioHeader);

Expand Down Expand Up @@ -131,15 +137,17 @@ public void visitEnd(final ScenarioModel scenarioModel) {
asciiDocBlocks.add(casesTableBlock);
}

final List<Tag> tags = scenarioModel.getTagIds().stream()
.map(this.featureTagMap::get)
.collect(Collectors.toList());

String scenarioFooter = blockConverter.convertScenarioFooterBlock(scenarioModel.getExecutionStatus(), tags);
String scenarioFooter = blockConverter.convertScenarioFooterBlock(scenarioModel.getExecutionStatus(), tagList);
asciiDocBlocks.add(scenarioFooter);
}

public List<String> getResult() {
return Collections.unmodifiableList(asciiDocBlocks);
}


public Map<String, Integer> getUsedTags() {
return Collections.unmodifiableMap(featureTagIds);
}

}

0 comments on commit b48c593

Please sign in to comment.