
jp.co.moneyforward.autotest.framework.action.Act Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of insdog-all Show documentation
Show all versions of insdog-all Show documentation
An action-based testing framework and library
The newest version!
package jp.co.moneyforward.autotest.framework.action;
import com.github.valid8j.pcond.forms.Printables;
import jp.co.moneyforward.autotest.framework.core.ExecutionEnvironment;
import jp.co.moneyforward.autotest.framework.internal.InternalUtils;
import java.util.function.Consumer;
import java.util.function.Function;
///
/// This interface represents the smallest and indivisible unit of action in **insdog** 's programming model.
///
public interface Act {
///
/// Applies this function the given argument: `value`(`T`) and returns the result (`R`).
///
/// @param value An argument value.
/// @param executionEnvironment An environment in which this function is executed.
/// @return the function result.
///
R perform(T value, ExecutionEnvironment executionEnvironment);
///
/// Returns a name of an instance of this interface.
///
/// @return A name of this instance.
///
default String name() {
return InternalUtils.simpleClassNameOf(this.getClass());
}
default Act describe(String description) {
return new Act<>() {
@Override
public R perform(T value, ExecutionEnvironment executionEnvironment) {
return Act.this.perform(value, executionEnvironment);
}
@Override
public String name() {
return description;
}
};
}
default Act andThen(Act next) {
return new Act<>() {
@Override
public S perform(T value, ExecutionEnvironment executionEnvironment) {
return next.perform(Act.this.perform(value, executionEnvironment), executionEnvironment);
}
@Override
public String name() {
return Act.this.name() + "->" + next.name();
}
};
}
static Act create(Function func) {
return new Func<>(func);
}
static Act create(String name, Function action) {
return create(Printables.function(name, action));
}
///
/// A leaf act, which represents a value assignment behavior.
///
/// @param The type of the value to be assigned.
///
class Let extends Source implements Act
© 2015 - 2025 Weber Informatics LLC | Privacy Policy