Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4539ea

Browse files
authored
Merge pull request #76 from utPLSQL/save-codestyle
Commit codestyle to the project and reformat all code
2 parents 85b7b14 + d8ab01c commit c4539ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+632
-511
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# IntelliJ
22
*.iml
3-
.idea/
3+
4+
.idea/*
5+
!/.idea/codeStyles
6+
!/.idea/dictionaries
47

58
# Maven
69
target/
@@ -21,3 +24,4 @@ buildNumber.properties
2124
#Exclude CoverageHTMLReporter resources as they are managed by maven
2225
src/main/resources/CoverageHTMLReporter/
2326
/gradle.properties
27+

.idea/codeStyles/Project.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dictionaries/utPLSQL.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/org/utplsql/api/CustomTypes.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public final class CustomTypes {
1717
public static final String UT_KEY_VALUE_PAIR = "UT_KEY_VALUE_PAIR";
1818
public static final String UT_KEY_VALUE_PAIRS = "UT_KEY_VALUE_PAIRS";
1919

20-
private CustomTypes() {}
20+
private CustomTypes() {
21+
}
2122

2223
}

src/main/java/org/utplsql/api/DBHelper.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
*/
1515
public final class DBHelper {
1616

17-
private DBHelper() {}
17+
private DBHelper() {
18+
}
1819

1920
/**
2021
* Return a new sys_guid from database.
22+
*
2123
* @param conn the connection
2224
* @return the new id string
2325
* @throws SQLException any database error
@@ -47,35 +49,38 @@ public static String getCurrentSchema(Connection conn) throws SQLException {
4749
}
4850
}
4951

50-
/** Returns the Frameworks version string of the given connection
52+
/**
53+
* Returns the Frameworks version string of the given connection
5154
* Deprecated. Use DatabaseInformation-Interface instead.
5255
*
5356
* @param conn Active db connection
5457
* @return Version-string of the utPLSQL framework
5558
* @throws SQLException any database error
5659
*/
5760
@Deprecated
58-
public static Version getDatabaseFrameworkVersion( Connection conn ) throws SQLException {
61+
public static Version getDatabaseFrameworkVersion(Connection conn) throws SQLException {
5962
DatabaseInformation databaseInformation = new DefaultDatabaseInformation();
6063
return databaseInformation.getUtPlsqlFrameworkVersion(conn);
6164

6265
}
6366

64-
/** Returns the Oracle database Version from a given connection object
67+
/**
68+
* Returns the Oracle database Version from a given connection object
6569
* Deprecated. Use DatabaseInformation-Interface instead.
6670
*
6771
* @param conn Connection-Object
6872
* @return Returns version-string of the Oracle Database product component
6973
* @throws SQLException any database error
7074
*/
7175
@Deprecated
72-
public static String getOracleDatabaseVersion( Connection conn ) throws SQLException {
76+
public static String getOracleDatabaseVersion(Connection conn) throws SQLException {
7377
DatabaseInformation databaseInformation = new DefaultDatabaseInformation();
7478
return databaseInformation.getOracleVersion(conn);
7579
}
7680

7781
/**
7882
* Enable the dbms_output buffer with unlimited size.
83+
*
7984
* @param conn the connection
8085
*/
8186
public static void enableDBMSOutput(Connection conn) {
@@ -88,6 +93,7 @@ public static void enableDBMSOutput(Connection conn) {
8893

8994
/**
9095
* Disable the dbms_output buffer.
96+
*
9197
* @param conn the connection
9298
*/
9399
public static void disableDBMSOutput(Connection conn) {

src/main/java/org/utplsql/api/EnvironmentVariableUtil.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
*/
2121
public class EnvironmentVariableUtil {
2222

23-
private EnvironmentVariableUtil() {}
23+
private EnvironmentVariableUtil() {
24+
}
2425

2526
/**
2627
* Returns the value for a given key from environment (see class description)

src/main/java/org/utplsql/api/FileMapper.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
public final class FileMapper {
1313

14-
private FileMapper() {}
14+
private FileMapper() {
15+
}
1516

1617
/**
1718
* Call the database api to build the custom file mappings.
@@ -27,15 +28,15 @@ public static Array buildFileMappingArray(
2728

2829
CallableStatement callableStatement = conn.prepareCall(
2930
"BEGIN " +
30-
"? := ut_file_mapper.build_file_mappings(" +
31+
"? := ut_file_mapper.build_file_mappings(" +
3132
"a_object_owner => ?, " +
3233
"a_file_paths => ?, " +
3334
"a_file_to_object_type_mapping => ?, " +
3435
"a_regex_pattern => ?, " +
3536
"a_object_owner_subexpression => ?, " +
3637
"a_object_name_subexpression => ?, " +
3738
"a_object_type_subexpression => ?); " +
38-
"END;");
39+
"END;");
3940

4041
int paramIdx = 0;
4142
callableStatement.registerOutParameter(++paramIdx, OracleTypes.ARRAY, CustomTypes.UT_FILE_MAPPINGS);

src/main/java/org/utplsql/api/FileMapping.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public class FileMapping implements SQLData {
1515
private String objectName;
1616
private String objectType;
1717

18-
public FileMapping() {}
18+
public FileMapping() {
19+
}
1920

2021
public FileMapping(String fileName, String objectOwner, String objectName, String objectType) {
2122
this.fileName = fileName;

src/main/java/org/utplsql/api/JavaApiVersionInfo.java

+15-10
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,38 @@
55
import java.io.InputStream;
66
import java.io.InputStreamReader;
77

8-
/** This class is getting updated automatically by the build process.
8+
/**
9+
* This class is getting updated automatically by the build process.
910
* Please do not update its constants manually cause they will be overwritten.
1011
*
1112
* @author pesse
1213
*/
1314
public class JavaApiVersionInfo {
1415

15-
private JavaApiVersionInfo() { }
16-
17-
1816
private static final String MAVEN_PROJECT_NAME = "utPLSQL-java-api";
1917
private static String MAVEN_PROJECT_VERSION = "unknown";
2018

2119
static {
2220
try {
2321

24-
try ( InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-api.version");
25-
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
22+
try (InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-api.version");
23+
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
2624
MAVEN_PROJECT_VERSION = reader.readLine();
2725
}
28-
}
29-
catch ( IOException e ) {
26+
} catch (IOException e) {
3027
System.out.println("WARNING: Could not get Version information!");
3128
}
3229
}
3330

34-
public static String getVersion() { return MAVEN_PROJECT_VERSION; }
35-
public static String getInfo() { return MAVEN_PROJECT_NAME + " " + getVersion(); }
31+
private JavaApiVersionInfo() {
32+
}
33+
34+
public static String getVersion() {
35+
return MAVEN_PROJECT_VERSION;
36+
}
37+
38+
public static String getInfo() {
39+
return MAVEN_PROJECT_NAME + " " + getVersion();
40+
}
3641

3742
}

src/main/java/org/utplsql/api/ResourceUtil.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
*/
2222
public class ResourceUtil {
2323

24-
private ResourceUtil() {}
24+
private ResourceUtil() {
25+
}
2526

2627
/**
2728
* Returns the Path to a resource so it is walkable no matter if it's inside a jar or on the file system
@@ -68,8 +69,9 @@ public static List<Path> getListOfChildren(Path resourceAsPath, boolean filesOnl
6869
// Get entry-path with root element so we can compare it
6970
Path entryPath = resourcePath.getRoot().resolve(resourcePath.getFileSystem().getPath(entry.toString()));
7071

71-
if (entryPath.startsWith(resourcePath) && (!filesOnly || !entry.isDirectory()))
72+
if (entryPath.startsWith(resourcePath) && (!filesOnly || !entry.isDirectory())) {
7273
result.add(entryPath.subpath(relativeStartIndex, entryPath.getNameCount()));
74+
}
7375
}
7476
}
7577
resourcePath.getFileSystem().close();

src/main/java/org/utplsql/api/TestRunner.java

+27-22
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public class TestRunner {
2828
private static final Logger logger = LoggerFactory.getLogger(TestRunner.class);
2929

3030
private final TestRunnerOptions options = new TestRunnerOptions();
31+
private final List<String> reporterNames = new ArrayList<>();
3132
private CompatibilityProxy compatibilityProxy;
3233
private ReporterFactory reporterFactory;
33-
private final List<String> reporterNames = new ArrayList<>();
3434

3535
public TestRunner addPath(String path) {
3636
options.pathList.add(path);
@@ -47,11 +47,12 @@ public TestRunner addReporter(Reporter reporter) {
4747
return this;
4848
}
4949

50-
public TestRunner addReporter( String reporterName ) {
51-
if ( reporterFactory != null )
50+
public TestRunner addReporter(String reporterName) {
51+
if (reporterFactory != null) {
5252
options.reporterList.add(reporterFactory.createReporter(reporterName));
53-
else
53+
} else {
5454
reporterNames.add(reporterName);
55+
}
5556
return this;
5657
}
5758

@@ -105,22 +106,22 @@ public TestRunner failOnErrors(boolean failOnErrors) {
105106
return this;
106107
}
107108

108-
public TestRunner skipCompatibilityCheck( boolean skipCompatibilityCheck )
109-
{
109+
public TestRunner skipCompatibilityCheck(boolean skipCompatibilityCheck) {
110110
options.skipCompatibilityCheck = skipCompatibilityCheck;
111111
return this;
112112
}
113113

114-
public TestRunner setReporterFactory( ReporterFactory reporterFactory ) {
114+
public TestRunner setReporterFactory(ReporterFactory reporterFactory) {
115115
this.reporterFactory = reporterFactory;
116116
return this;
117117
}
118118

119119
private void delayedAddReporters() {
120-
if ( reporterFactory != null )
121-
reporterNames.forEach( this::addReporter );
122-
else
120+
if (reporterFactory != null) {
121+
reporterNames.forEach(this::addReporter);
122+
} else {
123123
throw new IllegalStateException("ReporterFactory must be set to add delayed Reporters!");
124+
}
124125
}
125126

126127
public void run(Connection conn) throws SQLException {
@@ -132,17 +133,19 @@ public void run(Connection conn) throws SQLException {
132133
compatibilityProxy = new CompatibilityProxy(conn, options.skipCompatibilityCheck, databaseInformation);
133134
logger.info("Running on utPLSQL {}", compatibilityProxy.getDatabaseVersion());
134135

135-
if ( reporterFactory == null )
136+
if (reporterFactory == null) {
136137
reporterFactory = ReporterFactory.createDefault(compatibilityProxy);
138+
}
137139

138140
delayedAddReporters();
139141

140142
// First of all check version compatibility
141143
compatibilityProxy.failOnNotCompatible();
142144

143145
logger.info("Initializing reporters");
144-
for (Reporter r : options.reporterList)
146+
for (Reporter r : options.reporterList) {
145147
validateReporter(conn, r);
148+
}
146149

147150
if (options.pathList.isEmpty()) {
148151
options.pathList.add(databaseInformation.getCurrentSchema(conn));
@@ -153,43 +156,45 @@ public void run(Connection conn) throws SQLException {
153156
options.reporterList.add(new DocumentationReporter().init(conn));
154157
}
155158

156-
try(TestRunnerStatement testRunnerStatement = compatibilityProxy.getTestRunnerStatement(options, conn)) {
159+
try (TestRunnerStatement testRunnerStatement = compatibilityProxy.getTestRunnerStatement(options, conn)) {
157160
logger.info("Running tests");
158161
testRunnerStatement.execute();
159162
logger.info("Running tests finished.");
160163
} catch (SQLException e) {
161164
if (e.getErrorCode() == SomeTestsFailedException.ERROR_CODE) {
162165
throw new SomeTestsFailedException(e.getMessage(), e);
163-
}
164-
else if (e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE) {
166+
} else if (e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE) {
165167
throw new UtPLSQLNotInstalledException(e);
166-
}
167-
else {
168+
} else {
168169
throw e;
169170
}
170171
}
171172
}
172173

173174
/**
174175
* Check if the reporter was initialized, if not call reporter.init.
175-
* @param conn the database connection
176+
*
177+
* @param conn the database connection
176178
* @param reporter the reporter
177179
* @throws SQLException any sql exception
178180
*/
179181
private void validateReporter(Connection conn, Reporter reporter) throws SQLException {
180-
if (!reporter.isInit() || reporter.getId() == null || reporter.getId().isEmpty())
182+
if (!reporter.isInit() || reporter.getId() == null || reporter.getId().isEmpty()) {
181183
reporter.init(conn, compatibilityProxy, reporterFactory);
184+
}
182185
}
183186

184-
/** Returns the databaseVersion the TestRunner was run against
187+
/**
188+
* Returns the databaseVersion the TestRunner was run against
185189
*
186190
* @return Version of the database the TestRunner was run against
187191
*/
188192
public Version getUsedDatabaseVersion() {
189-
if ( compatibilityProxy != null )
193+
if (compatibilityProxy != null) {
190194
return compatibilityProxy.getDatabaseVersion();
191-
else
195+
} else {
192196
return null;
197+
}
193198
}
194199

195200
}

src/main/java/org/utplsql/api/TestRunnerOptions.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
import java.util.ArrayList;
77
import java.util.List;
88

9-
/** Holds the various possible options of TestRunner
9+
/**
10+
* Holds the various possible options of TestRunner
1011
*
1112
* @author pesse
1213
*/
1314
public class TestRunnerOptions {
1415
public final List<String> pathList = new ArrayList<>();
1516
public final List<Reporter> reporterList = new ArrayList<>();
16-
public boolean colorConsole = false;
1717
public final List<String> coverageSchemes = new ArrayList<>();
1818
public final List<String> sourceFiles = new ArrayList<>();
1919
public final List<String> testFiles = new ArrayList<>();
2020
public final List<String> includeObjects = new ArrayList<>();
2121
public final List<String> excludeObjects = new ArrayList<>();
22+
public boolean colorConsole = false;
2223
public FileMapperOptions sourceMappingOptions;
2324
public FileMapperOptions testMappingOptions;
2425
public boolean failOnErrors = false;

0 commit comments

Comments
 (0)