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

tech.grasshopper.extent.data.pojo.Step Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package tech.grasshopper.extent.data.pojo;

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.excel.report.exception.ExcelReportException;

@Data
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public class Step extends Executable {

	private String keyword;

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

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

	public void addBeforeStepHook(Hook hook) {
		before.add(hook);
	}

	public void addAfterStepHook(Hook hook) {
		after.add(hook);
	}

	public void checkData() {

		if (name == null || name.isEmpty())
			throw new ExcelReportException("Step text is null or empty.");

		if (keyword == null || keyword.isEmpty())
			throw new ExcelReportException("Keyword is null or empty for step - " + getName());

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

		super.checkData();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy