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

Commit507f675

Browse files
committed
Add custom mapping to TestRunner
1 parentaab76c9 commit507f675

File tree

4 files changed

+51
-38
lines changed

4 files changed

+51
-38
lines changed

‎src/main/java/io/github/utplsql/api/FileMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static Array buildFileMappingArray(
4343
intparamIdx =0;
4444
callableStatement.registerOutParameter(++paramIdx,OracleTypes.ARRAY,CustomTypes.UT_FILE_MAPPINGS);
4545

46-
callableStatement.setString(++paramIdx,mapperOptions.getOwner());
46+
callableStatement.setString(++paramIdx,mapperOptions.getObjectOwner());
4747
callableStatement.setArray(
4848
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_VARCHAR2_LIST,filePaths.toArray()));
4949
callableStatement.setArray(

‎src/main/java/io/github/utplsql/api/FileMapperOptions.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55

66
publicclassFileMapperOptions {
77

8-
privateStringowner;
8+
privateStringobjectOwner;
99
privateList<KeyValuePair>typeMappings;
1010
privateStringregexPattern;
1111
privateintownerSubExpression;
1212
privateinttypeSubExpression;
1313
privateintnameSubExpression;
1414

15-
publicFileMapperOptions(List<String>filePaths) {
15+
publicFileMapperOptions() {
1616
this.typeMappings =newArrayList<>();
1717
}
1818

19-
publicStringgetOwner() {
20-
returnowner;
19+
publicStringgetObjectOwner() {
20+
returnobjectOwner;
2121
}
2222

23-
publicvoidsetOwner(Stringowner) {
24-
this.owner =owner;
23+
publicvoidsetObjectOwner(Stringowner) {
24+
this.objectOwner =owner;
2525
}
2626

2727
publicList<KeyValuePair>getTypeMappings() {

‎src/main/java/io/github/utplsql/api/TestRunner.java

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
importio.github.utplsql.api.reporter.Reporter;
66
importoracle.jdbc.OracleConnection;
77

8-
importjava.sql.*;
8+
importjava.sql.CallableStatement;
9+
importjava.sql.Connection;
10+
importjava.sql.SQLException;
11+
importjava.sql.Types;
912
importjava.util.ArrayList;
1013
importjava.util.List;
1114

@@ -108,12 +111,12 @@ public void run(Connection conn) throws SomeTestsFailedException, SQLException {
108111
StringfailOnErrors =Boolean.toString(this.failOnErrors);
109112

110113
StringsourceFilesParam ="a_source_files";
111-
if (this.sourceMappingOptions !=null && !this.sourceFiles.isEmpty())
112-
sourceFilesParam ="a_source_file_mappings";
113-
114114
StringtestFilesParam ="a_test_files";
115-
if (this.testMappingOptions !=null && !this.testFiles.isEmpty())
116-
sourceFilesParam ="a_test_file_mappings";
115+
116+
if (this.sourceMappingOptions !=null ||this.testMappingOptions !=null) {
117+
sourceFilesParam ="a_source_file_mappings";
118+
testFilesParam ="a_test_file_mappings";
119+
}
117120

118121
OracleConnectionoraConn =conn.unwrap(OracleConnection.class);
119122
CallableStatementcallableStatement =null;
@@ -147,30 +150,40 @@ public void run(Connection conn) throws SomeTestsFailedException, SQLException {
147150
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_VARCHAR2_LIST,this.coverageSchemes.toArray()));
148151
}
149152

150-
if (this.sourceFiles.isEmpty()) {
151-
callableStatement.setNull(++paramIdx,Types.ARRAY,CustomTypes.UT_VARCHAR2_LIST);
152-
}elseif (this.sourceMappingOptions !=null) {
153-
ArraysourceMappings =FileMapper.buildFileMappingArray(
154-
conn,this.sourceFiles,this.sourceMappingOptions);
155-
156-
callableStatement.setArray(
157-
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_FILE_MAPPINGS,sourceMappings));
158-
}else {
159-
callableStatement.setArray(
160-
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_VARCHAR2_LIST,this.sourceFiles.toArray()));
161-
}
162-
163-
if (this.testFiles.isEmpty()) {
164-
callableStatement.setNull(++paramIdx,Types.ARRAY,CustomTypes.UT_VARCHAR2_LIST);
165-
}elseif (this.testMappingOptions !=null) {
166-
ArraysourceMappings =FileMapper.buildFileMappingArray(
167-
conn,this.testFiles,this.testMappingOptions);
168-
169-
callableStatement.setArray(
170-
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_FILE_MAPPINGS,sourceMappings));
153+
if (this.sourceMappingOptions !=null ||this.testMappingOptions !=null) {
154+
if (this.sourceMappingOptions !=null) {
155+
List<FileMapping>sourceMappings =FileMapper.buildFileMappingList(
156+
conn,this.sourceFiles,this.sourceMappingOptions);
157+
158+
callableStatement.setArray(
159+
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_FILE_MAPPINGS,sourceMappings.toArray()));
160+
}else {
161+
callableStatement.setNull(++paramIdx,Types.ARRAY,CustomTypes.UT_FILE_MAPPINGS);
162+
}
163+
164+
if (this.testMappingOptions !=null) {
165+
List<FileMapping>sourceMappings =FileMapper.buildFileMappingList(
166+
conn,this.testFiles,this.testMappingOptions);
167+
168+
callableStatement.setArray(
169+
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_FILE_MAPPINGS,sourceMappings.toArray()));
170+
}else {
171+
callableStatement.setNull(++paramIdx,Types.ARRAY,CustomTypes.UT_FILE_MAPPINGS);
172+
}
171173
}else {
172-
callableStatement.setArray(
173-
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_VARCHAR2_LIST,this.testFiles.toArray()));
174+
if (this.sourceFiles.isEmpty()) {
175+
callableStatement.setNull(++paramIdx,Types.ARRAY,CustomTypes.UT_VARCHAR2_LIST);
176+
}else {
177+
callableStatement.setArray(
178+
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_VARCHAR2_LIST,this.sourceFiles.toArray()));
179+
}
180+
181+
if (this.testFiles.isEmpty()) {
182+
callableStatement.setNull(++paramIdx,Types.ARRAY,CustomTypes.UT_VARCHAR2_LIST);
183+
}else {
184+
callableStatement.setArray(
185+
++paramIdx,oraConn.createOracleArray(CustomTypes.UT_VARCHAR2_LIST,this.testFiles.toArray()));
186+
}
174187
}
175188

176189
if (this.includeObjects.isEmpty()) {

‎src/test/java/io/github/utplsql/api/FileMapperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public void testFileMapper() throws SQLException {
2424
"sources/app/procedures/award_bonus.sql",
2525
"sources/app/functions/betwnstr.sql");
2626

27-
FileMapperOptionsmapperOptions =newFileMapperOptions(filePaths);
28-
mapperOptions.setOwner("APP");
27+
FileMapperOptionsmapperOptions =newFileMapperOptions();
28+
mapperOptions.setObjectOwner("APP");
2929
mapperOptions.setTypeMappings(typeMappings);
3030
mapperOptions.setRegexPattern("\\w+[\\\\\\/](\\w+)[\\\\\\/](\\w+)[\\\\\\/](\\w+)[.](\\w{3})");
3131
mapperOptions.setOwnerSubExpression(1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp