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

net.jqwik.engine.properties.CheckedFunction Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package net.jqwik.engine.properties;

import java.util.*;
import java.util.function.*;

import org.opentest4j.*;

import net.jqwik.api.lifecycle.*;
import net.jqwik.engine.execution.lifecycle.*;

@FunctionalInterface
public interface CheckedFunction extends Predicate>, TryExecutor, TryLifecycleExecutor {

	@Override
	default TryExecutionResult execute(List parameters) {
		try {
			boolean result = this.test(parameters);
			return result ? TryExecutionResult.satisfied() : TryExecutionResult.falsified(null);
		} catch (TestAbortedException tea) {
			return TryExecutionResult.invalid(tea);
		} catch (AssertionError | Exception e) {
			return TryExecutionResult.falsified(e);
		}
	}

	/**
	 * Only needed to simplify some tests
	 */
	@Override
	default TryExecutionResult execute(TryLifecycleContext tryLifecycleContext, List parameters) {
		return execute(parameters);
	}
}