net.serenitybdd.screenplay.BaseConsequence Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-journey Show documentation
Show all versions of serenity-journey Show documentation
Support for the User Journey pattern in Serenity
package net.serenitybdd.screenplay;
import net.thucydides.core.steps.StepEventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class BaseConsequence implements Consequence {
private Class extends Error> complaintType;
private String complaintDetails;
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
protected Error errorFrom(Throwable actualError) {
if (actualError instanceof Error) {
return (Error) actualError;
}
return new Error(actualError);
}
protected void throwComplaintTypeErrorIfSpecified(Error actualError) {
if (complaintType != null) {
LOGGER.error("Could not resolve question", actualError);
throw Complaint.from(complaintType, complaintDetails, actualError);
}
}
protected boolean thisStepShouldBeIgnored() {
return (StepEventBus.getEventBus().currentTestIsSuspended() || StepEventBus.getEventBus().aStepInTheCurrentTestHasFailed());
}
@Override
public BaseConsequence orComplainWith(Class extends Error> complaintType) {
return orComplainWith(complaintType, null);
}
@Override
public BaseConsequence orComplainWith(Class extends Error> complaintType, String complaintDetails) {
this.complaintType = complaintType;
this.complaintDetails = complaintDetails;
return this;
}
}