Skip to content

Commit 236a95a

Browse files
committed
Package changes
1 parent ec292cf commit 236a95a

File tree

11 files changed

+74
-55
lines changed

11 files changed

+74
-55
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.github.utplsql.api;
2+
3+
/**
4+
* Database custom data reporter.
5+
*/
6+
public final class CustomTypes {
7+
8+
// Object names must be upper case.
9+
public static final String UT_REPORTERS = "UT_REPORTERS";
10+
public static final String UT_DOCUMENTATION_REPORTER = "UT_DOCUMENTATION_REPORTER";
11+
public static final String UT_COVERAGE_HTML_REPORTER = "UT_COVERAGE_HTML_REPORTER";
12+
public static final String UT_VARCHAR2_LIST = "UT_VARCHAR2_LIST";
13+
14+
private CustomTypes() {}
15+
16+
}

src/main/java/io/github/utplsql/api/OutputBuffer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.github.utplsql.api;
22

3-
import io.github.utplsql.api.types.BaseReporter;
3+
import io.github.utplsql.api.reporter.Reporter;
44
import oracle.jdbc.OracleTypes;
55

66
import java.io.PrintStream;
@@ -13,21 +13,21 @@
1313
*/
1414
public class OutputBuffer {
1515

16-
private BaseReporter reporter;
16+
private Reporter reporter;
1717

1818
/**
1919
* Creates a new OutputBuffer.
2020
* @param reporter the reporter to be used
2121
*/
22-
public OutputBuffer(BaseReporter reporter) {
22+
public OutputBuffer(Reporter reporter) {
2323
this.reporter = reporter;
2424
}
2525

2626
/**
2727
* Returns the reporter used by this buffer.
2828
* @return the reporter instance
2929
*/
30-
public BaseReporter getReporter() {
30+
public Reporter getReporter() {
3131
return reporter;
3232
}
3333

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.github.utplsql.api;
22

3-
import io.github.utplsql.api.types.BaseReporter;
4-
import io.github.utplsql.api.types.CustomTypes;
3+
import io.github.utplsql.api.reporter.Reporter;
54
import oracle.jdbc.OracleConnection;
65

76
import java.sql.Array;
@@ -17,7 +16,7 @@ public class TestRunner {
1716

1817
public TestRunner() {}
1918

20-
public void run(Connection conn, String path, BaseReporter reporter) throws SQLException {
19+
public void run(Connection conn, String path, Reporter reporter) throws SQLException {
2120
validateReporter(conn, reporter);
2221
CallableStatement callableStatement = null;
2322
try {
@@ -31,8 +30,8 @@ public void run(Connection conn, String path, BaseReporter reporter) throws SQLE
3130
}
3231
}
3332

34-
public void run(Connection conn, List<String> pathList, List<BaseReporter> reporterList) throws SQLException {
35-
for (BaseReporter r : reporterList)
33+
public void run(Connection conn, List<String> pathList, List<Reporter> reporterList) throws SQLException {
34+
for (Reporter r : reporterList)
3635
validateReporter(conn, r);
3736

3837
OracleConnection oraConn = conn.unwrap(OracleConnection.class);
@@ -57,7 +56,7 @@ public void run(Connection conn, List<String> pathList, List<BaseReporter> repor
5756
* @param reporter the reporter
5857
* @throws SQLException any sql exception
5958
*/
60-
private void validateReporter(Connection conn, BaseReporter reporter) throws SQLException {
59+
private void validateReporter(Connection conn, Reporter reporter) throws SQLException {
6160
if (reporter.getReporterId() == null || reporter.getReporterId().isEmpty())
6261
reporter.init(conn);
6362
}

src/main/java/io/github/utplsql/api/types/CoverageHTMLReporter.java renamed to src/main/java/io/github/utplsql/api/reporter/CoverageHTMLReporter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
package io.github.utplsql.api.types;
1+
package io.github.utplsql.api.reporter;
2+
3+
import io.github.utplsql.api.CustomTypes;
24

35
import java.sql.SQLException;
46

57
/**
68
* Created by Vinicius on 13/04/2017.
79
*/
8-
public class CoverageHTMLReporter extends BaseReporter {
10+
public class CoverageHTMLReporter extends Reporter {
911

1012
@Override
1113
public String getSQLTypeName() throws SQLException {

src/main/java/io/github/utplsql/api/types/DocumentationReporter.java renamed to src/main/java/io/github/utplsql/api/reporter/DocumentationReporter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
package io.github.utplsql.api.types;
1+
package io.github.utplsql.api.reporter;
2+
3+
import io.github.utplsql.api.CustomTypes;
24

35
import java.sql.SQLException;
46

57
/**
68
* Created by Vinicius on 13/04/2017.
79
*/
8-
public class DocumentationReporter extends BaseReporter {
10+
public class DocumentationReporter extends Reporter {
911

1012
@Override
1113
public String getSQLTypeName() throws SQLException {

src/main/java/io/github/utplsql/api/types/BaseReporter.java renamed to src/main/java/io/github/utplsql/api/reporter/Reporter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.utplsql.api.types;
1+
package io.github.utplsql.api.reporter;
22

33
import io.github.utplsql.api.DBHelper;
44

@@ -8,15 +8,15 @@
88
/**
99
* Created by Vinicius on 13/04/2017.
1010
*/
11-
public abstract class BaseReporter implements SQLData {
11+
public abstract class Reporter implements SQLData {
1212

1313
private String selfType;
1414
private String reporterId;
1515
private java.sql.Date startDate;
1616

17-
public BaseReporter() {}
17+
public Reporter() {}
1818

19-
public BaseReporter init(Connection conn) throws SQLException {
19+
public Reporter init(Connection conn) throws SQLException {
2020
setStartDate(new java.sql.Date(Calendar.getInstance().getTimeInMillis()));
2121
setReporterId(DBHelper.newSysGuid(conn));
2222
return this;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.github.utplsql.api.reporter;
2+
3+
import io.github.utplsql.api.CustomTypes;
4+
5+
/**
6+
* Created by vinicius.moreira on 22/05/2017.
7+
*/
8+
public final class ReporterFactory {
9+
10+
private ReporterFactory() {}
11+
12+
public static Reporter createReporter(String reporterName) {
13+
switch (reporterName.toUpperCase()) {
14+
case CustomTypes.UT_DOCUMENTATION_REPORTER: return new DocumentationReporter();
15+
case CustomTypes.UT_COVERAGE_HTML_REPORTER: return new CoverageHTMLReporter();
16+
}
17+
throw new RuntimeException("Reporter " + reporterName + " not implemented.");
18+
}
19+
20+
}

src/main/java/io/github/utplsql/api/types/CustomTypes.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/test/java/io/github/utplsql/api/OutputBufferTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.github.utplsql.api;
22

33
import io.github.utplsql.api.rules.DatabaseRule;
4-
import io.github.utplsql.api.types.BaseReporter;
5-
import io.github.utplsql.api.types.DocumentationReporter;
4+
import io.github.utplsql.api.reporter.Reporter;
5+
import io.github.utplsql.api.reporter.DocumentationReporter;
66
import org.junit.Assert;
77
import org.junit.Rule;
88
import org.junit.Test;
@@ -23,9 +23,9 @@ public class OutputBufferTest {
2323
@Rule
2424
public final DatabaseRule db = new DatabaseRule();
2525

26-
public BaseReporter createReporter() throws SQLException {
26+
public Reporter createReporter() throws SQLException {
2727
Connection conn = db.newConnection();
28-
BaseReporter reporter = new DocumentationReporter().init(conn);
28+
Reporter reporter = new DocumentationReporter().init(conn);
2929
System.out.println("Reporter ID: " + reporter.getReporterId());
3030
return reporter;
3131
}
@@ -35,7 +35,7 @@ public void printAvailableLines() {
3535
ExecutorService executorService = Executors.newFixedThreadPool(2);
3636

3737
try {
38-
final BaseReporter reporter = createReporter();
38+
final Reporter reporter = createReporter();
3939

4040
Future<Object> task1 = executorService.submit(() -> {
4141
try {
@@ -91,7 +91,7 @@ public void printAvailableLines() {
9191
@Test
9292
public void fetchAllLines() {
9393
try {
94-
final BaseReporter reporter = createReporter();
94+
final Reporter reporter = createReporter();
9595
Connection conn = db.newConnection();
9696
new TestRunner().run(conn, "", reporter);
9797

src/test/java/io/github/utplsql/api/TestRunnerTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.github.utplsql.api;
22

33
import io.github.utplsql.api.rules.DatabaseRule;
4-
import io.github.utplsql.api.types.BaseReporter;
5-
import io.github.utplsql.api.types.CoverageHTMLReporter;
6-
import io.github.utplsql.api.types.DocumentationReporter;
4+
import io.github.utplsql.api.reporter.Reporter;
5+
import io.github.utplsql.api.reporter.CoverageHTMLReporter;
6+
import io.github.utplsql.api.reporter.DocumentationReporter;
77
import org.junit.Assert;
88
import org.junit.Rule;
99
import org.junit.Test;
@@ -25,8 +25,8 @@ public class TestRunnerTest {
2525
public void runWithDocumentationReporter() {
2626
try {
2727
Connection conn = db.newConnection();
28-
BaseReporter reporter = new DocumentationReporter();
29-
new TestRunner().run(conn, "", reporter);
28+
Reporter reporter = new DocumentationReporter();
29+
new TestRunner().run(conn, db.getUser(), reporter);
3030
Assert.assertNotNull(reporter.getReporterId());
3131
} catch (SQLException e) {
3232
Assert.fail(e.getMessage());
@@ -39,9 +39,9 @@ public void runWithTwoReporters() {
3939
Connection conn = db.newConnection();
4040

4141
List<String> pathList = new ArrayList<>();
42-
pathList.add("app");
42+
pathList.add(db.getUser());
4343

44-
List<BaseReporter> reporterList = new ArrayList<>();
44+
List<Reporter> reporterList = new ArrayList<>();
4545
reporterList.add(new DocumentationReporter().init(conn));
4646
reporterList.add(new CoverageHTMLReporter().init(conn));
4747

src/test/java/io/github/utplsql/api/rules/DatabaseRule.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public DatabaseRule() {
2929
connectionList = new ArrayList<>();
3030
}
3131

32+
public String getUser() {
33+
return sUser;
34+
}
35+
3236
public synchronized Connection newConnection() throws SQLException {
3337
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" + sUrl, sUser, sPass);
3438
connectionList.add(conn);

0 commit comments

Comments
 (0)