Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0e5b5eb

Browse files
committed
Convert the RunCommand-properties into the new Config-Objects first
1 parent2c682e9 commit0e5b5eb

File tree

4 files changed

+152
-6
lines changed

4 files changed

+152
-6
lines changed

‎src/main/java/org/utplsql/cli/RunCommand.java

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
importorg.utplsql.api.exception.DatabaseNotCompatibleException;
1111
importorg.utplsql.api.exception.SomeTestsFailedException;
1212
importorg.utplsql.api.exception.UtPLSQLNotInstalledException;
13+
importorg.utplsql.api.reporter.CoreReporters;
1314
importorg.utplsql.api.reporter.Reporter;
1415
importorg.utplsql.api.reporter.ReporterFactory;
16+
importorg.utplsql.cli.config.ReporterConfig;
17+
importorg.utplsql.cli.config.TestRunnerConfig;
1518
importorg.utplsql.cli.exception.DatabaseConnectionFailed;
1619

1720
importjavax.sql.DataSource;
@@ -36,10 +39,10 @@ public class RunCommand implements ICommand {
3639

3740
@Parameter(
3841
required =true,
39-
converter =ConnectionInfo.ConnectionStringConverter.class,
42+
//converter = ConnectionInfo.ConnectionStringConverter.class,
4043
arity =1,
4144
description =ConnectionInfo.COMMANDLINE_PARAM_DESCRIPTION)
42-
privateList<ConnectionInfo>connectionInfoList =newArrayList<>();
45+
privateStringconnectionInfo ="";
4346

4447
@Parameter(
4548
names = {"-p","--path"},
@@ -100,12 +103,16 @@ public class RunCommand implements ICommand {
100103
privateStringexcludeObjects =null;
101104

102105

106+
privateConnectionInfoconnectionInfoObj;
103107
privateCompatibilityProxycompatibilityProxy;
104108
privateReporterFactoryreporterFactory;
105109
privateReporterManagerreporterManager;
106110

107111
publicConnectionInfogetConnectionInfo() {
108-
returnconnectionInfoList.get(0);
112+
if (connectionInfoObj ==null )
113+
connectionInfoObj =newConnectionInfo(connectionInfo);
114+
115+
returnconnectionInfoObj;
109116
}
110117

111118
publicList<String>getTestPaths() {
@@ -326,4 +333,81 @@ private ReporterManager getReporterManager() {
326333
publicList<ReporterOptions>getReporterOptionsList() {
327334
returngetReporterManager().getReporterOptionsList();
328335
}
336+
337+
privateList<ReporterConfig>getReporterConfigs() {
338+
List<ReporterConfig>reporterConfigs =newArrayList<>(5);
339+
340+
StringreporterName =null;
341+
StringoutputFile =null;
342+
BooleanforceToScreen =null;
343+
for (Stringp :reporterParams) {
344+
if (!p.startsWith("-")) {
345+
if (reporterName !=null ) {
346+
reporterConfigs.add(newReporterConfig(reporterName,outputFile,forceToScreen));
347+
reporterName =null;
348+
outputFile =null;
349+
forceToScreen =null;
350+
}
351+
reporterName =p;
352+
}
353+
elseif (p.startsWith("-o="))
354+
outputFile =p.substring(3);
355+
elseif (p.equals("-s"))
356+
forceToScreen =true;
357+
}
358+
359+
if (reporterName !=null )
360+
reporterConfigs.add(newReporterConfig(reporterName,outputFile,forceToScreen));
361+
362+
returnreporterConfigs;
363+
}
364+
365+
privateString[]getSplitList(StringdelimitedList ) {
366+
if (delimitedList !=null && !delimitedList.isEmpty() )
367+
returndelimitedList.split(",");
368+
else
369+
returnnull;
370+
}
371+
372+
publicTestRunnerConfiggetConfig() {
373+
finalList<Reporter>reporterList;
374+
List<ReporterOptions>reporterOptionsList =newArrayList<>();
375+
ReporterOptionsreporterOptions =null;
376+
377+
List<ReporterConfig>reporterConfigs =getReporterConfigs();
378+
379+
// If no reporter parameters were passed, use default reporter.
380+
if (reporterOptionsList.isEmpty()) {
381+
reporterOptionsList.add(newReporterOptions(CoreReporters.UT_DOCUMENTATION_REPORTER.name()));
382+
}
383+
finalList<String>testPaths =getTestPaths();
384+
385+
finalFilebaseDir =newFile("").getAbsoluteFile();
386+
finalFileMapperOptions[]sourceMappingOptions = {null};
387+
finalFileMapperOptions[]testMappingOptions = {null};
388+
389+
finalint[]returnCode = {0};
390+
391+
sourceMappingOptions[0] =getFileMapperOptionsByParamListItem(this.sourcePathParams,baseDir);
392+
testMappingOptions[0] =getFileMapperOptionsByParamListItem(this.testPathParams,baseDir);
393+
394+
String[]testPathArr =newString[testPaths.size()];
395+
testPathArr =testPaths.toArray(testPathArr);
396+
397+
ReporterConfig[]reporterConfigArr =newReporterConfig[reporterConfigs.size()];
398+
reporterConfigArr =reporterConfigs.toArray(reporterConfigArr);
399+
400+
returnnewTestRunnerConfig(
401+
connectionInfo,
402+
testPathArr,
403+
reporterConfigArr,
404+
colorConsole,
405+
failureExitCode,
406+
skipCompatibilityCheck,
407+
getSplitList(includeObjects),
408+
getSplitList(excludeObjects),
409+
null,
410+
null
411+
);
412+
}
329413
}

‎src/main/java/org/utplsql/cli/config/ReporterConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public class ReporterConfig {
99
privatebooleanscreen =false;
1010

1111
@ConstructorProperties({"name","output","screen"})
12-
publicReporterConfig(Stringname,Stringoutput,booleanscreen ) {
12+
publicReporterConfig(Stringname,Stringoutput,Booleanscreen ) {
1313
this.name =name;
1414
this.output =output;
15-
this.screen =screen;
15+
if (screen !=null )this.screen =screen;
1616
}
1717

1818
publicStringgetName() {

‎src/test/java/org/utplsql/cli/YmlConfigTest.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
packageorg.utplsql.cli;
22

3+
importcom.beust.jcommander.JCommander;
34
importcom.fasterxml.jackson.databind.ObjectMapper;
45
importcom.fasterxml.jackson.dataformat.yaml.YAMLFactory;
56
importorg.apache.commons.lang3.builder.ReflectionToStringBuilder;
@@ -10,6 +11,10 @@
1011
importjava.io.File;
1112
importjava.io.IOException;
1213

14+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
15+
importstaticorg.junit.jupiter.api.Assertions.assertNull;
16+
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
17+
1318
publicclassYmlConfigTest {
1419

1520
@Test
@@ -21,7 +26,38 @@ public void letsPlayAround() throws IOException {
2126

2227
TestRunnerConfigconfig =mapper.readValue(newFile(testConfigFile),TestRunnerConfig.class);
2328

24-
System.out.println(ReflectionToStringBuilder.toString(config,ToStringStyle.MULTI_LINE_STYLE));
29+
System.out.println(ReflectionToStringBuilder.toString(config,ToStringStyle.MULTI_LINE_STYLE));
30+
}
31+
32+
@Test
33+
publicvoidconfigTest() {
34+
JCommanderjc =newJCommander();
35+
jc.setProgramName("utplsql");
36+
37+
CommandProvidercmdProvider =newCommandProvider();
38+
39+
cmdProvider.commands().forEach(cmd ->jc.addCommand(cmd.getCommand(),cmd));
40+
41+
jc.parse("run",TestHelper.getConnectionString(),
42+
"-f=ut_coverage_html_reporter","-o=test.html",
43+
"-f=ut_documentation_reporter","-s",
44+
"-exclude=app.award_bonus,app.betwnstr");
45+
46+
RunCommandcmd = (RunCommand)cmdProvider.getCommand(jc.getParsedCommand());
47+
48+
TestRunnerConfigconfig =cmd.getConfig();
49+
50+
assertEquals(TestHelper.getConnectionString(),config.getConnectString());
51+
assertEquals(2,config.getReporters().length);
52+
assertEquals("ut_coverage_html_reporter",config.getReporters()[0].getName());
53+
assertEquals("test.html",config.getReporters()[0].getOutput());
54+
assertEquals(false,config.getReporters()[0].isScreen());
55+
assertEquals("ut_documentation_reporter",config.getReporters()[1].getName());
56+
assertNull(config.getReporters()[1].getOutput());
57+
assertEquals(true,config.getReporters()[1].isScreen());
58+
assertEquals("app.award_bonus",config.getExcludePackages()[0]);
59+
assertEquals("app.betwnstr",config.getExcludePackages()[1]);
60+
2561
}
2662

2763

‎src/test/resources/test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
utPLSQL-cli/bin/utplsql run test_runner/pass@db_url \
2+
-p=hr,app \
3+
-f=ut_documentation_reporter \
4+
-f=ut_coverage_html_reporter \
5+
-o=coverage.html \
6+
-f=ut_sonar_test_reporter \
7+
-o=sonar.txt \
8+
-s \
9+
-c \
10+
--failure-exit-code=2 \
11+
-scc \
12+
-include=app.betwnstr,mypackage \
13+
-exclude=mypackage.blugg,stuff \
14+
-source_path=sources \
15+
-regex_expression="/(\w+)/(\w+)/(\w+)\..{3}$" \
16+
-type_mapping="packages_bodies=PACKAGE BODY/types_bodies=TYPE BODY/triggers=TRIGGER/procedures=PROCEDURE/functions=FUNCTION" \
17+
-owner_subexpression=2 \
18+
-name_subexpression=3 \
19+
-type_subexpression=4 \
20+
-test_path=tests -regex_expression="/(\w+)/(\w+)/(\w+)\..{3}$" \
21+
-type_mapping="body=PACKAGE BODY/type_body=TYPE BODY/trigger=TRIGGER" \
22+
-owner_subexpression=2 \
23+
-name_subexpression=3 \
24+
-type_subexpression=4 \
25+
-f=ut_coverage_html_reporter -o=coverage.html \
26+
-f=ut_sonar_test_reporter -o=test_results.xml

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp