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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 4 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.platform.version>1.0.3</junit.platform.version>
<junit.jupiter.version>5.0.3</junit.jupiter.version>
<junit.jupiter.version>5.4.0</junit.jupiter.version>
<travisBuildNumber>local</travisBuildNumber>
</properties>

Expand Down Expand Up @@ -58,13 +57,7 @@
<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -94,24 +87,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>2.22.0</version>
<configuration>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<version>2.22.0</version>
<executions>
<execution>
<goals>
Expand All @@ -120,13 +106,6 @@
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<resources>
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/utplsql/cli/CliVersionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
*/
public class CliVersionInfo {

private static final String MAVEN_PROJECT_NAME = "utPLSL-cli";
private static final String MAVEN_PROJECT_NAME = "utPLSQL-cli";
private static String MAVEN_PROJECT_VERSION = "unknown";

static {
try {
try ( InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-cli.version")) {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
try ( InputStream in = JavaApiVersionInfo.class.getClassLoader().getResourceAsStream("utplsql-cli.version");
BufferedReader reader = new BufferedReader(new InputStreamReader(in)) ) {
MAVEN_PROJECT_VERSION = reader.readLine();

reader.close();
}
}
catch ( IOException e ) {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/utplsql/cli/CommandProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
import java.util.Map;
import java.util.stream.Stream;

public class CommandProvider {
class CommandProvider {

private Map<String, ICommand> commands;
private JCommander jCommander;
private final Map<String, ICommand> commands = new HashMap<>();
private final JCommander jCommander;

public CommandProvider( JCommander jCommander ) {
this.jCommander = jCommander;
init();
}

private void init() {
commands = new HashMap<>();

addCommand(new RunCommand());
addCommand(new VersionInfoCommand());
addCommand(new ReportersCommand());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/utplsql/cli/ConnectionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class ConnectionInfo {

public static final String COMMANDLINE_PARAM_DESCRIPTION = "<user>/<password>@//<host>[:<port>]/<service> OR <user>/<password>@<TNSName> OR <user>/<password>@<host>:<port>:<SID>";
private String connectionInfo;
private final String connectionInfo;

public ConnectionInfo(String connectionInfo) {
this.connectionInfo = connectionInfo;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/utplsql/cli/ConnectionInfoBuilder.java

This file was deleted.

5 changes: 3 additions & 2 deletions src/main/java/org/utplsql/cli/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
*/
public class HelpCommand implements ICommand {

private String errorMessage;
private JCommander jCommander;
private final String errorMessage;
private final JCommander jCommander;

public HelpCommand(JCommander jCommander) {
this.jCommander = jCommander;
this.errorMessage = null;
}

public HelpCommand( JCommander jCommander, String errorMessage ) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/utplsql/cli/ReporterFactoryProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @author pesse
*/
public class ReporterFactoryProvider {
class ReporterFactoryProvider {

public static ReporterFactory createReporterFactory(CompatibilityProxy proxy ) {
ReporterFactory reporterFactory = ReporterFactory.createDefault(proxy);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/utplsql/cli/ReporterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ public List<ReporterOptions> getReporterOptionsList() {
return reporterOptionsList;
}

public int getNumberOfReporters() { return reporterOptionsList.size(); };
public int getNumberOfReporters() { return reporterOptionsList.size(); }
}
53 changes: 16 additions & 37 deletions src/main/java/org/utplsql/cli/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,10 @@ public class RunCommand implements ICommand {
private ReporterFactory reporterFactory;
private ReporterManager reporterManager;

public ConnectionInfo getConnectionInfo() {
private ConnectionInfo getConnectionInfo() {
return connectionInfoList.get(0);
}

public List<String> getTestPaths() {
return testPaths;
}

void init() {

LoggerConfiguration.ConfigLevel level = LoggerConfiguration.ConfigLevel.BASIC;
Expand All @@ -144,7 +140,6 @@ public int run() {
try {

final List<Reporter> reporterList;
final List<String> testPaths = getTestPaths();

final File baseDir = new File("").getAbsoluteFile();
final FileMapperOptions[] sourceMappingOptions = {null};
Expand All @@ -155,23 +150,8 @@ public int run() {
sourceMappingOptions[0] = getFileMapperOptionsByParamListItem(this.sourcePathParams, baseDir);
testMappingOptions[0] = getFileMapperOptionsByParamListItem(this.testPathParams, baseDir);

ArrayList<String> includeObjectsList;
ArrayList<String> excludeObjectsList;

if (includeObjects != null && !includeObjects.isEmpty()) {
includeObjectsList = new ArrayList<>(Arrays.asList(includeObjects.split(",")));
} else {
includeObjectsList = new ArrayList<>();
}

if (excludeObjects != null && !excludeObjects.isEmpty()) {
excludeObjectsList = new ArrayList<>(Arrays.asList(excludeObjects.split(",")));
} else {
excludeObjectsList = new ArrayList<>();
}

final ArrayList<String> finalIncludeObjectsList = includeObjectsList;
final ArrayList<String> finalExcludeObjectsList = excludeObjectsList;
final List<String> finalIncludeObjectsList = getObjectList(includeObjects);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 😅

final List<String> finalExcludeObjectsList = getObjectList(excludeObjects);

final DataSource dataSource = DataSourceProvider.getDataSource(getConnectionInfo(), getReporterManager().getNumberOfReporters() + 1);

Expand Down Expand Up @@ -231,6 +211,16 @@ public int run() {
return 1;
}

private ArrayList<String> getObjectList(String includeObjects) {
ArrayList<String> includeObjectsList;
if (includeObjects != null && !includeObjects.isEmpty()) {
includeObjectsList = new ArrayList<>(Arrays.asList(includeObjects.split(",")));
} else {
includeObjectsList = new ArrayList<>();
}
return includeObjectsList;
}

@Override
public String getCommand() {
return "run";
Expand All @@ -239,7 +229,7 @@ public String getCommand() {

private void outputMainInformation() {

StringBlockFormatter formatter = new StringBlockFormatter("utPLCSL cli");
StringBlockFormatter formatter = new StringBlockFormatter("utPLSQL cli");
formatter.appendLine(CliVersionInfo.getInfo());
formatter.appendLine(JavaApiVersionInfo.getInfo());
formatter.appendLine("Java-Version: " + System.getProperty("java.version"));
Expand Down Expand Up @@ -317,7 +307,7 @@ private CompatibilityProxy checkFrameworkCompatibility(Connection conn) throws S
return proxy;
}

public FileMapperOptions getMapperOptions(List<String> mappingParams, List<String> filePaths) {
private FileMapperOptions getMapperOptions(List<String> mappingParams, List<String> filePaths) {
FileMapperOptions mapperOptions = new FileMapperOptions(filePaths);

final String OPT_OWNER="-owner=";
Expand Down Expand Up @@ -364,25 +354,14 @@ public FileMapperOptions getMapperOptions(List<String> mappingParams, List<Strin
return mapperOptions;
}

/** Returns the version of the database framework if available
*
* @return
*/
public Version getDatabaseVersion() {
if ( compatibilityProxy != null )
return compatibilityProxy.getDatabaseVersion();

return null;
}

private ReporterManager getReporterManager() {
if ( reporterManager == null )
reporterManager = new ReporterManager(reporterParams);

return reporterManager;
}

public List<ReporterOptions> getReporterOptionsList() {
List<ReporterOptions> getReporterOptionsList() {
return getReporterManager().getReporterOptionsList();
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/utplsql/cli/VersionInfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class VersionInfoCommand implements ICommand {
description = ConnectionInfo.COMMANDLINE_PARAM_DESCRIPTION)
private List<ConnectionInfo> connectionInfoList = new ArrayList<>();

public ConnectionInfo getConnectionInfo() {
private ConnectionInfo getConnectionInfo() {
if ( connectionInfoList != null && connectionInfoList.size() > 0 )
return connectionInfoList.get(0);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface ConnectStringPossibility {

private static final Logger logger = LoggerFactory.getLogger(TestedDataSourceProvider.class);
private final ConnectionConfig config;
private List<ConnectStringPossibility> possibilities = new ArrayList<>();
private final List<ConnectStringPossibility> possibilities = new ArrayList<>();

public TestedDataSourceProvider(ConnectionConfig config) {
this.config = config;
Expand Down Expand Up @@ -52,8 +52,8 @@ private void setThickOrThinJdbcUrl(HikariDataSource ds ) throws SQLException

for (ConnectStringPossibility possibility : possibilities) {
ds.setJdbcUrl(possibility.getConnectString(config));
try (Connection con = ds.getConnection()) {
logger.info("Use connectstring {}", possibility.getMaskedConnectString(config));
try (Connection ignored = ds.getConnection()) {
logger.info("Use connection string {}", possibility.getMaskedConnectString(config));
return;
} catch (UnsatisfiedLinkError | Exception e) {
errors.add(possibility.getMaskedConnectString(config) + ": " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class StringBlockFormatter {

private String headline;
private StringBuilder content = new StringBuilder();
private final StringBuilder content = new StringBuilder();

public StringBlockFormatter() {}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/utplsql/cli/CliHelpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import org.junit.jupiter.api.Test;

public class CliHelpTest {
class CliHelpTest {

@Test
public void showBasicHelp() {
void showBasicHelp() {
TestHelper.runApp("help");
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/utplsql/cli/CliVersionInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import static org.junit.jupiter.api.Assertions.assertTrue;

public class CliVersionInfoTest {
class CliVersionInfoTest {

@Test
void getCliVersionInfo() {
Expand Down
Loading