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

tech.grasshopper.pdf.pojo.cucumber.Scenario Maven / Gradle / Ivy

The newest version!
package tech.grasshopper.pdf.pojo.cucumber;

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

import lombok.Builder.Default;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
import tech.grasshopper.pdf.config.ReportConfig;
import tech.grasshopper.pdf.config.StepHookFilter;
import tech.grasshopper.pdf.exception.PdfReportException;

@Data
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public class Scenario extends NonExecutable {

	private Feature feature;

	@Default
	private List before = new ArrayList<>();
	@Default
	private List steps = new ArrayList<>();
	@Default
	private List after = new ArrayList<>();

	@Default
	private int passedSteps = 0;
	@Default
	private int failedSteps = 0;
	@Default
	private int skippedSteps = 0;
	@Default
	private int totalSteps = 0;

	public List getBeforeAfterHooks() {
		List hooks = new ArrayList<>();
		hooks.addAll(before);
		hooks.addAll(after);
		return hooks;
	}

	public List getStepsAndHooks() {
		return StepHookFilter.allExecutables(steps, before, after);
	}

	public List getFilteredStepsAndHooks(ReportConfig reportConfig) {
		return StepHookFilter.filterExecutables(reportConfig, steps, before, after);
	}

	@Override
	public void checkData() {

		if (name == null || name.isEmpty())
			throw new PdfReportException("Scenario name is null or empty.");

		if (feature == null)
			throw new PdfReportException("No feature present for scenario - " + getName());

		if (steps == null || steps.isEmpty())
			throw new PdfReportException("No steps present for scenario - " + getName());

		if (status == null)
			throw new PdfReportException("No status present for scenario - " + getName());

		super.checkData();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy