net.jqwik.engine.execution.lifecycle.PlainExecutionResult Maven / Gradle / Ivy
package net.jqwik.engine.execution.lifecycle;
import java.util.*;
import net.jqwik.api.*;
import net.jqwik.api.lifecycle.*;
import net.jqwik.engine.execution.*;
public class PlainExecutionResult implements ExtendedPropertyExecutionResult {
public static ExtendedPropertyExecutionResult successful() {
return new PlainExecutionResult(Status.SUCCESSFUL, new GenerationInfo(null), null);
}
public static ExtendedPropertyExecutionResult failed(Throwable throwable, String seed) {
if (throwable == null) {
throw new IllegalArgumentException("throwable must never be null for failed PropertyExecutionResult");
}
return new PlainExecutionResult(Status.FAILED, new GenerationInfo(seed), throwable);
}
public static ExtendedPropertyExecutionResult aborted(Throwable throwable, String seed) {
return aborted(throwable, new GenerationInfo(seed));
}
public static ExtendedPropertyExecutionResult aborted(Throwable throwable, GenerationInfo generationInfo) {
if (throwable == null) {
throw new IllegalArgumentException("throwable must never be null for aborted PropertyExecutionResult");
}
return new PlainExecutionResult(Status.ABORTED, generationInfo, throwable);
}
private final Status status;
private final GenerationInfo generationInfo;
private final Throwable throwable;
private PlainExecutionResult(Status status, GenerationInfo generationInfo, Throwable throwable) {
this.status = status;
this.generationInfo = generationInfo;
this.throwable = throwable;
}
@Override
public Optional> falsifiedParameters() {
return Optional.empty();
}
@Override
public Status status() {
return status;
}
@Override
public Optional throwable() {
return Optional.ofNullable(throwable);
}
@Override
public PropertyExecutionResult mapTo(Status newStatus, Throwable throwable) {
return new PlainExecutionResult(newStatus, generationInfo, throwable);
}
@Override
public boolean isExtended() {
return false;
}
@Override
public int countChecks() {
return 0;
}
@Override
public int countTries() {
return 0;
}
@Override
public Optional originalSample() {
return Optional.empty();
}
@Override
public Optional shrunkSample() {
return Optional.empty();
}
@Override
public GenerationMode generation() {
return GenerationMode.NOT_SET;
}
@Override
public EdgeCasesExecutionResult edgeCases() {
return new EdgeCasesExecutionResult(EdgeCasesMode.NOT_SET, 0, 0);
}
@Override
public GenerationInfo generationInfo() {
return generationInfo;
}
@Override
public String toString() {
return String.format("PlainExecutionResult[%s]", status);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy