All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rest.RestScenarioResult Maven / Gradle / Ivy

Go to download

Rest Cucumber allows you to attach a rest client for retrieval of Cucumber feature files and posting of Cucumber test results

There is a newer version: 1.3
Show newest version
package rest;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class RestScenarioResult {
   private static final String PASSED_STEP_RESULT = "[passed]";
   private static final String PASS_SCENARIO_RESULT = "pass";
   private static final String FAIL_SCENARIO_RESULT = "fail";
   private Map stepsWithResults;
   private List passedSteps;
   private List failedSteps;
   private String scenario;
   private String scenarioResult;

   public RestScenarioResult(String scenario, Map stepsWithResults) {
      this.scenario = scenario;
      this.stepsWithResults = stepsWithResults;
      passedSteps = new ArrayList();
      failedSteps = new ArrayList();
      calculateResult();
   }

   private void calculateResult() {
      for (String step : stepsWithResults.keySet()) {
         String stepResult = stepsWithResults.get(step);
         if (PASSED_STEP_RESULT.equalsIgnoreCase(stepResult)) {
            passedSteps.add(step);
         } else {
            failedSteps.add(step);
         }
      }
      scenarioResult =
         failedSteps.isEmpty() ? PASS_SCENARIO_RESULT : FAIL_SCENARIO_RESULT;
      if (failedSteps.isEmpty() && passedSteps.isEmpty()) {
         scenarioResult = FAIL_SCENARIO_RESULT;
      }
   }

   public String getScenario() {
      return scenario;
   }

   public String getScenarioResult() {
      return scenarioResult;
   }

   public Map getStepsWithResults() {
      return stepsWithResults;
   }

   public String toString() {
      return scenario + ", " + scenarioResult;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy