com.epam.reportportal.cucumber.RunningContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agent-java-cucumber Show documentation
Show all versions of agent-java-cucumber Show documentation
EPAM Report portal. Cucumber JVM version [1.0.0; 2.0.0) adapter
package com.epam.reportportal.cucumber;
import com.epam.reportportal.listeners.ItemStatus;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import gherkin.formatter.model.Step;
import io.reactivex.Maybe;
import javax.annotation.Nonnull;
import java.util.ArrayDeque;
import java.util.Queue;
/**
* Running context that contains mostly manipulations with Gherkin objects.
* Keeps necessary information regarding current Feature, Scenario and Step
*
* @author Vadzim Hushchanskou
*/
public class RunningContext {
private RunningContext() {
throw new AssertionError("No instances should exist for the class!");
}
public static class FeatureContext {
private final String uri;
private Maybe id;
private StartTestItemRQ itemRq;
public FeatureContext(String featureUri) {
uri = featureUri;
}
public void setId(Maybe newId) {
id = newId;
}
public Maybe getId() {
return id;
}
public StartTestItemRQ getItemRq() {
return itemRq;
}
public void setItemRq(StartTestItemRQ startRq) {
itemRq = startRq;
}
public String getUri() {
return uri;
}
}
public static class ScenarioContext {
private boolean inBackground;
private String stepPrefix;
private Maybe currentStepId;
private Maybe hookStepId;
private ItemStatus hookStatus;
private final Queue steps;
private final Queue outlineIterations;
private Maybe id;
private ItemStatus status;
private Integer line;
private String featureUri;
public ScenarioContext() {
stepPrefix = "";
steps = new ArrayDeque<>();
outlineIterations = new ArrayDeque<>();
status = ItemStatus.PASSED;
}
@Nonnull
public Queue getOutlineIterations() {
return outlineIterations;
}
public void setId(Maybe id) {
this.id = id;
}
public boolean isInBackground() {
return inBackground;
}
public void setInBackground(boolean inBackground) {
this.inBackground = inBackground;
}
public String getStepPrefix() {
return stepPrefix;
}
public void setStepPrefix(String prefix) {
stepPrefix = prefix;
}
public Maybe getCurrentStepId() {
return currentStepId;
}
public void setCurrentStepId(Maybe currentStepId) {
this.currentStepId = currentStepId;
}
public Maybe getHookStepId() {
return hookStepId;
}
public void setHookStepId(Maybe hookStepId) {
this.hookStepId = hookStepId;
}
public ItemStatus getHookStatus() {
return hookStatus;
}
public void setHookStatus(ItemStatus hookStatus) {
this.hookStatus = hookStatus;
}
public Maybe getId() {
return id;
}
public void addStep(Step step) {
steps.add(step);
}
public Step getNextStep() {
return steps.poll();
}
public boolean noMoreSteps() {
return steps.isEmpty();
}
public void updateStatus(ItemStatus newStatus) {
if (status != newStatus) {
if (ItemStatus.FAILED != status) {
status = newStatus;
}
}
}
public ItemStatus getStatus() {
return status;
}
public Integer getLine() {
return line;
}
public void setLine(Integer scenarioLine) {
line = scenarioLine;
}
public void setFeatureUri(String featureUri) {
this.featureUri = featureUri;
}
public String getFeatureUri() {
return featureUri;
}
}
}