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

Skip to content

Commit a7b8266

Browse files
committed
Adding TestFileMappings
1 parent 5ff0ee2 commit a7b8266

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/main/java/org/utplsql/api/testRunner/DynamicTestRunnerStatement.java

+4
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ private DynamicParameterList initParameterList() throws SQLException {
5555
Object[] sourceMappings = (options.sourceMappingOptions!=null)
5656
?FileMapper.buildFileMappingList(oracleConnection, options.sourceMappingOptions).toArray()
5757
:null;
58+
Object[] testMappings = (options.testMappingOptions!=null)
59+
?FileMapper.buildFileMappingList(oracleConnection, options.testMappingOptions).toArray()
60+
:null;
5861
return DynamicParameterList.builder()
5962
.addIfNotEmpty("a_paths", options.pathList.toArray(), CustomTypes.UT_VARCHAR2_LIST, oracleConnection)
6063
.addIfNotEmpty("a_reporters", options.reporterList.toArray(), CustomTypes.UT_REPORTERS, oracleConnection)
6164
.addIfNotEmpty("a_color_console", options.colorConsole)
6265
.addIfNotEmpty("a_coverage_schemes", options.coverageSchemes.toArray(), CustomTypes.UT_VARCHAR2_LIST, oracleConnection)
6366
.addIfNotEmpty("a_source_file_mappings", sourceMappings, CustomTypes.UT_FILE_MAPPINGS, oracleConnection)
67+
.addIfNotEmpty("a_test_file_mappings", testMappings, CustomTypes.UT_FILE_MAPPINGS, oracleConnection)
6468
.build();
6569
}
6670

src/test/java/org/utplsql/api/testRunner/DynamicTestRunnerStatementTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import java.sql.Array;
1111
import java.sql.CallableStatement;
1212
import java.sql.SQLException;
13-
import java.util.List;
14-
import java.util.concurrent.Callable;
1513

1614
import static org.hamcrest.CoreMatchers.containsString;
1715
import static org.hamcrest.MatcherAssert.assertThat;
@@ -22,8 +20,7 @@ public class DynamicTestRunnerStatementTest {
2220
@Test
2321
void explore() throws SQLException {
2422
// Expectation objects
25-
Object[] expectedSourceFileMapping = new Object[]{new FileMapping("source", "owner", "source", "PACKAGE")};
26-
Object[] expectedTestFileMapping = new Object[]{new FileMapping("test", "owner", "test", "PACKAGE")};
23+
Object[] expectedFileMapping = new Object[]{new FileMapping("someFile", "owner", "object", "PACKAGE")};
2724

2825
// Mock some internals. This is not pretty, but a first step
2926
OracleConnection oracleConnection = mock(OracleConnection.class);
@@ -42,7 +39,7 @@ void explore() throws SQLException {
4239
when(fileMapperStatement.getArray(1))
4340
.thenReturn(fileMapperArray);
4441
when(fileMapperArray.getArray())
45-
.thenReturn(expectedSourceFileMapping);
42+
.thenReturn(expectedFileMapping);
4643

4744
// Act
4845
TestRunnerOptions options = TestRunnerStatementProviderIT.getCompletelyFilledOptions();
@@ -85,7 +82,10 @@ void explore() throws SQLException {
8582

8683
assertThat(testRunnerStatement.getSql(), containsString("a_source_file_mappings => ?"));
8784
verify(callableStatement).setArray(5, null);
88-
verify(oracleConnection).createOracleArray(CustomTypes.UT_FILE_MAPPINGS, expectedSourceFileMapping);
85+
86+
assertThat(testRunnerStatement.getSql(), containsString("a_test_file_mappings => ?"));
87+
verify(callableStatement).setArray(6, null);
88+
verify(oracleConnection, times(2)).createOracleArray(CustomTypes.UT_FILE_MAPPINGS, expectedFileMapping);
8989

9090

9191
}

0 commit comments

Comments
 (0)