Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor to Builder-pattern for RunCommandConfig
  • Loading branch information
pesse committed Mar 12, 2020
commit 1bc62661eccf2acde07b908f9620e6e60e15effa
37 changes: 19 additions & 18 deletions src/main/java/org/utplsql/cli/RunPicocliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,25 @@ public RunCommandConfig getRunCommandConfig() {
}
}

return new RunCommandConfig(
connectionString,
suitePaths.toArray(new String[0]),
reporterConfigs.toArray(new ReporterConfig[0]),
colorConsole,
failureExitCode,
skipCompatibilityCheck,
splitOrEmpty(includeObjects),
splitOrEmpty(excludeObjects),
sourceFileMapping,
testFileMapping,
loggerConfigLevel,
timeoutInMinutes,
enableDbmsOutput,
randomTestOrder,
randomTestOrderSeed,
tags.toArray(new String[0]),
coverageSchemes.toArray(new String[0]));
return new RunCommandConfig.Builder()
.connectString(connectionString)
.suitePaths(suitePaths.toArray(new String[0]))
.reporters(reporterConfigs.toArray(new ReporterConfig[0]))
.outputAnsiColor(colorConsole)
.failureExitCode(failureExitCode)
.skipCompatibilityCheck(skipCompatibilityCheck)
.includePackages(splitOrEmpty(includeObjects))
.excludePackages(splitOrEmpty(excludeObjects))
.sourceMapping(sourceFileMapping)
.testMapping(testFileMapping)
.logConfigLevel(loggerConfigLevel)
.timeoutInMinutes(timeoutInMinutes)
.dbmsOutput(enableDbmsOutput)
.randomTestOrder(randomTestOrder)
.randomTestOrderSeed(randomTestOrderSeed)
.tags(tags.toArray(new String[0]))
.coverageSchemes(coverageSchemes.toArray(new String[0]))
.create();
}

private RunAction getRunAction() {
Expand Down
114 changes: 113 additions & 1 deletion src/main/java/org/utplsql/cli/config/RunCommandConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,117 @@ public Integer getRandomTestOrderSeed() {
return randomTestOrderSeed;
}

public String[] getCoverageSchemes() { return coverageSchemes; }
public String[] getCoverageSchemes() {
return coverageSchemes;
}

public static class Builder {

private String connectString;
private String[] suitePaths;
private ReporterConfig[] reporters;
private boolean outputAnsiColor;
private Integer failureExitCode;
private boolean skipCompatibilityCheck;
private String[] includePackages;
private String[] excludePackages;
private FileMapperConfig sourceMapping;
private FileMapperConfig testMapping;
private ConfigLevel logConfigLevel;
private Integer timeoutInMinutes;
private boolean dbmsOutput;
private boolean randomTestOrder;
private Integer randomTestOrderSeed;
private String[] tags;
private String[] coverageSchemes;

public Builder connectString(String connectString) {
this.connectString = connectString;
return this;
}

public Builder suitePaths(String[] suitePaths) {
this.suitePaths = suitePaths;
return this;
}

public Builder reporters(ReporterConfig[] reporters) {
this.reporters = reporters;
return this;
}

public Builder outputAnsiColor(boolean outputAnsiColor) {
this.outputAnsiColor = outputAnsiColor;
return this;
}

public Builder failureExitCode(Integer failureExitCode) {
this.failureExitCode = failureExitCode;
return this;
}

public Builder skipCompatibilityCheck(boolean skipCompatibilityCheck) {
this.skipCompatibilityCheck = skipCompatibilityCheck;
return this;
}

public Builder includePackages(String[] includePackages) {
this.includePackages = includePackages;
return this;
}

public Builder excludePackages(String[] excludePackages) {
this.excludePackages = excludePackages;
return this;
}

public Builder sourceMapping(FileMapperConfig sourceMapping) {
this.sourceMapping = sourceMapping;
return this;
}

public Builder testMapping(FileMapperConfig testMapping) {
this.testMapping = testMapping;
return this;
}

public Builder logConfigLevel(ConfigLevel logConfigLevel) {
this.logConfigLevel = logConfigLevel;
return this;
}

public Builder timeoutInMinutes(Integer timeoutInMinutes) {
this.timeoutInMinutes = timeoutInMinutes;
return this;
}

public Builder dbmsOutput(boolean dbmsOutput) {
this.dbmsOutput = dbmsOutput;
return this;
}

public Builder randomTestOrder(boolean randomTestOrder) {
this.randomTestOrder = randomTestOrder;
return this;
}

public Builder randomTestOrderSeed(Integer randomTestOrderSeed) {
this.randomTestOrderSeed = randomTestOrderSeed;
return this;
}

public Builder tags(String[] tags) {
this.tags = tags;
return this;
}

public Builder coverageSchemes(String[] coverageSchemes) {
this.coverageSchemes = coverageSchemes;
return this;
}

public RunCommandConfig create() {
return new RunCommandConfig(connectString, suitePaths, reporters, outputAnsiColor, failureExitCode, skipCompatibilityCheck, includePackages, excludePackages, sourceMapping, testMapping, logConfigLevel, timeoutInMinutes, dbmsOutput, randomTestOrder, randomTestOrderSeed, tags, coverageSchemes);
}
}
}