package com.github.bogdanlivadariu.reporting.cucumber.builder;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import com.github.bogdanlivadariu.reporting.cucumber.helpers.Constants;
import com.github.bogdanlivadariu.reporting.cucumber.json.models.Feature;
import com.github.bogdanlivadariu.reporting.cucumber.json.models.Tag;

public class AllFeatureReports {

    private String pageTitle;

    private List<Feature> features;

    private int scenariosTotal;

    private int scenariosTotalPassed;

    private int scenariosTotalFailed;

    private int stepsTotal;

    private int stepsTotalPassed;

    private int stepsTotalFailed;

    private int stepsTotalSkipped;

    private int stepsTotalUndefined;

    private long totalDuration;

    private Set<String> allTags = new LinkedHashSet<String>();

    public AllFeatureReports(String pageTitle, List<Feature> features) {
        this.features = features;
        this.pageTitle = pageTitle;
        for (Feature feature : this.features) {
            scenariosTotal += feature.getElements().length;
            scenariosTotalPassed += feature.getScenariosPassedCount();
            scenariosTotalFailed += feature.getScenariosFailedCount();

            stepsTotal += feature.getStepsTotalCount();
            stepsTotalPassed += feature.getStepsPassedCount();
            stepsTotalFailed += feature.getStepsFailedCount();
            stepsTotalSkipped += feature.getStepsSkippedCount();
            stepsTotalUndefined += feature.getStepsUndefinedCount();

            totalDuration += feature.getTotalDuration();

            if (feature.getTags().length < 1) {
                allTags.add(Constants.UNTAGGED);
            } else {
                for (Tag tag : feature.getTags()) {
                    allTags.add(tag.getName());
                }
            }
        }
    }

    public List<Feature> getFeatures() {
        return features;
    }

    public int getScenariosTotal() {
        return scenariosTotal;
    }

    public int getScenariosTotalPassed() {
        return scenariosTotalPassed;
    }

    public int getScenariosTotalFailed() {
        return scenariosTotalFailed;
    }

    public int getStepsTotal() {
        return stepsTotal;
    }

    public int getStepsTotalPassed() {
        return stepsTotalPassed;
    }

    public int getStepsTotalFailed() {
        return stepsTotalFailed;
    }

    public int getStepsTotalSkipped() {
        return stepsTotalSkipped;
    }

    public int getStepsTotalUndefined() {
        return stepsTotalUndefined;
    }

    public long getTotalDuration() {
        return totalDuration;
    }

    public int getFeaturesCount() {
        return features.size();
    }

    public String getPageTitle() {
        return pageTitle;
    }

    public List<String> getAllTags() {
        // Collections.sort(allTags);
        List<String> sortegTags = new ArrayList<String>(allTags);
        Collections.sort(sortegTags);
        return sortegTags;
    }

}

@@ -516,35 +516,39 @@
 s;%0A%0A    private 
-i
+I
 nt
+eger
  scenariosTotal;
@@ -553,35 +553,39 @@
 l;%0A%0A    private 
-i
+I
 nt
+eger
  scenariosTotalP
@@ -604,19 +604,23 @@
 private 
-i
+I
 nt
+eger
  scenari
@@ -639,35 +639,39 @@
 d;%0A%0A    private 
-i
+I
 nt
+eger
  stepsTotal;%0A%0A  
@@ -672,35 +672,39 @@
 l;%0A%0A    private 
-i
+I
 nt
+eger
  stepsTotalPasse
@@ -711,35 +711,39 @@
 d;%0A%0A    private 
-i
+I
 nt
+eger
  stepsTotalFaile
@@ -750,35 +750,39 @@
 d;%0A%0A    private 
-i
+I
 nt
+eger
  stepsTotalSkipp
@@ -798,19 +798,23 @@
 private 
-i
+I
 nt
+eger
  stepsTo
@@ -840,17 +840,17 @@
 private 
-l
+L
 ong tota
@@ -2037,35 +2037,39 @@
   %7D%0A%0A    public 
-i
+I
 nt
+eger
  getScenariosTot
@@ -2116,35 +2116,39 @@
   %7D%0A%0A    public 
-i
+I
 nt
+eger
  getScenariosTot
@@ -2211,27 +2211,31 @@
 %0A    public 
-i
+I
 nt
+eger
  getScenario
@@ -2298,35 +2298,39 @@
   %7D%0A%0A    public 
-i
+I
 nt
+eger
  getStepsTotal()
@@ -2369,35 +2369,39 @@
   %7D%0A%0A    public 
-i
+I
 nt
+eger
  getStepsTotalPa
@@ -2452,35 +2452,39 @@
   %7D%0A%0A    public 
-i
+I
 nt
+eger
  getStepsTotalFa
@@ -2535,35 +2535,39 @@
   %7D%0A%0A    public 
-i
+I
 nt
+eger
  getStepsTotalSk
@@ -2624,27 +2624,31 @@
 %0A    public 
-i
+I
 nt
+eger
  getStepsTot
@@ -2717,17 +2717,17 @@
  public 
-l
+L
 ong getT
@@ -2795,11 +2795,15 @@
 lic 
-i
+I
 nt
+eger
  get

move away from primitives