com.xlrit.gears.runner.driver.RunConfig Maven / Gradle / Ivy
The newest version!
package com.xlrit.gears.runner.driver;
import java.util.Iterator;
import com.fasterxml.jackson.databind.JsonNode;
import com.xlrit.gears.base.util.DisplayedHelper;
import static com.xlrit.gears.runner.utils.CommandLineUtils.*;
public class RunConfig extends Config {
public String scenarioDir = "scenarios";
public String target = "graphql";
public int waitMillis = 200;
public int timeoutMillis = 10000;
public int typeMillis = 50;
public int clickMillis = 250;
public boolean failFast = false;
public boolean renderForms = true;
public boolean headless = false;
public boolean submitScreenshots = false;
public boolean expandedReport = false;
public boolean slow = false;
@Override
protected void readArg(String arg, Iterator args) {
switch (arg) {
case "--scenario-dir" -> setString(args, "ScenarioDir", value -> scenarioDir = value);
case "--target" -> setString(args, "Target", value -> target = value);
case "--timeout-millis" -> setInteger(args, "TimeoutMillis", value -> timeoutMillis = value);
case "--wait-millis" -> setInteger(args, "WaitMillis", value -> waitMillis = value);
case "--type-millis" -> setInteger(args, "TypeMillis", value -> typeMillis = value);
case "--click-millis" -> setInteger(args, "ClickMillis", value -> clickMillis = value);
case "--headless" -> headless = true;
case "--submit-screenshots" -> submitScreenshots = true;
case "--fail-fast" -> failFast = true;
case "--expanded-report" -> expandedReport = true;
case "--slow" -> slow = true;
default -> super.readArg(arg, args);
}
}
@Override
public void readJson(JsonNode configNode) {
super.readJson(configNode);
JsonNode options = configNode.get("runnerOptions");
if (options != null) {
timeoutMillis = orElseInt(options.get("timeoutMillis"), timeoutMillis);
waitMillis = orElseInt(options.get("waitMillis"), waitMillis);
target = orElseString(options.get("target"), target);
failFast = orElseBool(options.get("failFast"), failFast);
renderForms = orElseBool(options.get("renderForms"), renderForms);
headless = orElseBool(options.get("headless"), headless);
submitScreenshots = orElseBool(options.get("submitScreenshots"), submitScreenshots);
expandedReport = orElseBool(options.get("expandedReport"), expandedReport);
}
JsonNode dirs = configNode.get("dirs");
if (dirs != null) {
scenarioDir = orElseString(dirs.get("scenarios"), scenarioDir);
}
}
@Override
protected DisplayedHelper getDisplayedHelper() {
return super.getDisplayedHelper()
.add("scenarioDir", scenarioDir)
.add("target", target)
.add("waitMillis", waitMillis)
.add("timeoutMillis", timeoutMillis)
.add("typeMillis", typeMillis)
.add("clickMillis", clickMillis)
.add("failFast", failFast)
.add("renderForms", renderForms)
.add("headless", headless)
.add("submitScreenshots", submitScreenshots)
.add("expandedReport", expandedReport)
.add("slow", slow);
}
}