8000 Refactor to Builder-pattern for RunCommandConfig · pen-dev/utPLSQL-cli@1bc6266 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1bc6266

Browse files
committed
Refactor to Builder-pattern for RunCommandConfig
1 parent efe4e53 commit 1bc6266

File tree

2 files changed

+132
-19
lines changed

2 files changed

+132
-19
lines changed

src/main/java/org/utplsql/cli/RunPicocliCommand.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,25 @@ public RunCommandConfig getRunCommandConfig() {
227227
}
228228
}
229229

230-
return new RunCommandConfig(
231-
connectionString,
232-
suitePaths.toArray(new String[0]),
233-
reporterConfigs.toArray(new ReporterConfig[0]),
234-
colorConsole,
235-
failureExitCode,
236-
skipCompatibilityCheck,
237-
splitOrEmpty(includeObjects),
238-
splitOrEmpty(excludeObjects),
239-
sourceFileMapping,
240-
testFileMapping,
241-
loggerConfigLevel,
242-
timeoutInMinutes,
243-
enableDbmsOutput,
244-
randomTestOrder,
245-
randomTestOrderSeed,
246-
tags.toArray(new String[0]),
247-
coverageSchemes.toArray(new String[0]));
230+
return new RunCommandConfig.Builder()
231+
.connectString(connectionString)
232+
.suitePaths(suitePaths.toArray(new String[0]))
233+
.reporters(reporterConfigs.toArray(new ReporterConfig[0]))
234+
.outputAnsiColor(colorConsole)
235+
.failureExitCode(failureExitCode)
236+
.skipCompatibilityCheck(skipCompatibilityCheck)
237+
.includePackages(splitOrEmpty(includeObjects))
238+
.excludePackages(splitOrEmpty(excludeObjects))
239+
.sourceMapping(sourceFileMapping)
240+
.testMapping(testFileMapping)
241+
.logConfigLevel(loggerConfigLevel)
242+
.timeoutInMinutes(timeoutInMinutes)
243+
.dbmsOutput(enableDbmsOutput)
244+
.randomTestOrder(randomTestOrder)
245+
.randomTestOrderSeed(randomTestOrderSeed)
246+
.tags(tags.toArray(new String[0]))
247+
.coverageSchemes(coverageSchemes.toArray(new String[0]))
248+
.create();
248249
}
249250

250251
private RunAction getRunAction() {

src/main/java/org/utplsql/cli/config/RunCommandConfig.java

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,117 @@ public Integer getRandomTestOrderSeed() {
105105
return randomTestOrderSeed;
106106
}
107107

108-
public String[] getCoverageSchemes() { return coverageSchemes; }
108+
public String[] getCoverageSchemes() {
109+
return coverageSchemes;
110+
}
111+
112+
public static class Builder {
113+
114+
private String connectString;
115+
private String[] suitePaths;
116+
private ReporterConfig[] reporters;
117+
private boolean outputAnsiColor;
118+
private Integer failureExitCode;
119+
private boolean skipCompatibilityCheck;
120+
private String[] includePackages;
121+
private String[] excludePackages;
122+
private FileMapperConfig sourceMapping;
123+
private FileMapperConfig testMapping;
124+
private ConfigLevel logConfigLevel;
125+
private Integer timeoutInMinutes;
126+
private boolean dbmsOutput;
127+
private boolean randomTestOrder;
128+
private Integer randomTestOrderSeed;
129+
private String[] tags;
130+
private String[] coverageSchemes;
131+
132+
public Builder connectString(String connectString) {
133+
this.connectString = connectString;
134+
return this;
135+
}
136+
137+
public Builder suitePaths(String[] suitePaths) {
138+
this.suitePaths = suitePaths;
139+
return this;
140+
}
141+
142+
public Builder reporters(ReporterConfig[] reporters) {
143+
this.reporters = reporters;
144+
return this;
145+
}
146+
147+
public Builder outputAnsiColor(boolean outputAnsiColor) {
148+
this.outputAnsiColor = outputAnsiColor;
149+
return this;
150+
}
151+
152+
public Builder failureExitCode(Integer failureExitCode) {
153+
this.failureExitCode = failureExitCode;
154+
return this;
155+
}
156+
157+
public Builder skipCompatibilityCheck(boolean skipCompatibilityCheck) {
158+
this.skipCompatibilityCheck = skipCompatibilityCheck;
159+
return this;
160+
}
161+
162+
public Builder includePackages(String[] includePackages) {
163+
this.includePackages = includePackages;
164+
return this;
165+
}
166+
167+
public Builder excludePackages(String[] excludePackages) {
168+
this.excludePackages = excludePackages;
169+
return this;
170+
}
171+
172+
public Builder sourceMapping(FileMapperConfig sourceMapping) {
173+
this.sourceMapping = sourceMapping;
174+
return this;
175+
}
176+
177+
public Builder testMapping(FileMapperConfig testMapping) {
178+
this.testMapping = testMapping;
179+
return this;
180+
}
181+
182+
public Builder logConfigLevel(ConfigLevel logConfigLevel) {
183+
this.logConfigLevel = logConfigLevel;
184+
return this;
185+
}
186+
187+
public Builder timeoutInMinutes(Integer timeoutInMinutes) {
188+
this.timeoutInMinutes = timeoutInMinutes;
189+
return this;
190+
}
191+
192+
public Builder dbmsOutput(boolean dbmsOutput) {
193+
this.dbmsOutput = dbmsOutput;
194+
return this;
195+
}
196+
197+
public Builder randomTestOrder(boolean randomTestOrder) {
198+
this.randomTestOrder = randomTestOrder;
199+
return this;
200+
}
201+
202+
public Builder randomTestOrderSeed(Integer randomTestOrderSeed) {
203+
this.randomTestOrderSeed = randomTestOrderSeed;
204+
return this;
205+
}
206+
207+
public Builder tags(String[] tags) {
208+
this.tags = tags;
209+
return this;
210+
}
211+
212+
public Builder coverageSchemes(String[] coverageSchemes) {
213+
this.coverageSchemes = coverageSchemes;
214+
return this;
215+
}
216+
217+
public RunCommandConfig create() {
218+
return new RunCommandConfig(connectString, suitePaths, reporters, outputAnsiColor, failureExitCode, skipCompatibilityCheck, includePackages, excludePackages, sourceMapping, testMapping, logConfigLevel, timeoutInMinutes, dbmsOutput, randomTestOrder, randomTestOrderSeed, tags, coverageSchemes);
219+
}
220+
}
109221
}

0 commit comments

Comments
 (0)
0