class RuleScenarioRunnerHelper extends AbstractRunnerHelper {

    @SuppressWarnings("unchecked")
    @Override
    protected ScenarioResultMetadata extractResultMetadata(Map<String, Object> requestContext, ScenarioWithIndex scenarioWithIndex) {
        CoverageAgendaListener coverageAgendaListener = (CoverageAgendaListener) requestContext.get(COVERAGE_LISTENER);
        Map<String, Integer> ruleExecuted = coverageAgendaListener.getRuleExecuted();
        Set<String> availableRules = (Set<String>) requestContext.get(RULES_AVAILABLE);
        ScenarioResultMetadata scenarioResultMetadata = new ScenarioResultMetadata(scenarioWithIndex);
        scenarioResultMetadata.addAllAvailable(availableRules);
        scenarioResultMetadata.addAllExecuted(ruleExecuted);
        final AtomicInteger counter = new AtomicInteger(0);
        coverageAgendaListener.getAuditsMessages().forEach(auditMessage ->
                scenarioResultMetadata.addAuditMessage(counter.addAndGet(1), auditMessage, ConstantsHolder.EXECUTED));
        return scenarioResultMetadata;
    }

}