3
3
import org .apache .commons .lang3 .tuple .Pair ;
4
4
import org .apache .maven .plugin .MojoExecutionException ;
5
5
import org .apache .maven .plugin .testing .MojoRule ;
6
- import org .junit .Assert ;
7
6
import org .junit .Before ;
8
7
import org .junit .Rule ;
9
8
import org .junit .Test ;
29
28
30
29
import static org .junit .Assert .assertEquals ;
31
30
import static org .junit .Assert .assertFalse ;
31
+ import static org .junit .Assert .assertNotNull ;
32
+ import static org .junit .Assert .assertThrows ;
32
33
import static org .junit .Assert .assertTrue ;
33
34
import static org .mockito .ArgumentMatchers .anyString ;
34
35
import static org .mockito .Mockito .mock ;
@@ -64,7 +65,7 @@ public void setUp() throws Exception {
64
65
}
65
66
66
67
/**
67
- * testInvalidSourcesDirectory.
68
+ * Invalid Sources Directory
68
69
* <p>
69
70
* Given : a pom.xml with invalid sources' directory
70
71
* When : pom is read and buildSourcesOptions is run
@@ -74,15 +75,15 @@ public void setUp() throws Exception {
74
75
public void testInvalidSourcesDirectory () throws Exception {
75
76
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
76
77
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/invalidTestsSourcesDirectories/" ), "test" );
77
- Assert . assertNotNull (utplsqlMojo );
78
+ assertNotNull (utplsqlMojo );
78
79
79
- MojoExecutionException exception = Assert . assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" ));
80
+ MojoExecutionException exception = assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" ));
80
81
81
- Assert . assertEquals ("Invalid <SOURCES> in your pom.xml" , exception .getMessage ());
82
+ assertEquals ("Invalid <SOURCES> in your pom.xml" , exception .getMessage ());
82
83
}
83
84
84
85
/**
85
- * testInvalidTestsDirectory.
86
+ * Invalid Tests Directory
86
87
* <p>
87
88
* Given : a pom.xml with invalid tests' directory
88
89
* When : pom is read and buildTestsOptions is run
@@ -92,15 +93,15 @@ public void testInvalidSourcesDirectory() throws Exception {
92
93
public void testInvalidTestsDirectory () throws Exception {
93
94
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
94
95
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/invalidTestsSourcesDirectories/" ), "test" );
95
- Assert . assertNotNull (utplsqlMojo );
96
+ assertNotNull (utplsqlMojo );
96
97
97
- MojoExecutionException exception = Assert . assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildTestsOptions" ));
98
+ MojoExecutionException exception = assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildTestsOptions" ));
98
99
99
- Assert . assertEquals ("Invalid <TESTS> in your pom.xml: Invalid <directory> bar in resource. Check your pom.xml" , exception .getMessage ());
100
+ assertEquals ("Invalid <TESTS> in your pom.xml: Invalid <directory> bar in resource. Check your pom.xml" , exception .getMessage ());
100
101
}
101
102
102
103
/**
103
- * testSourcesTestsParameters.
104
+ * Sources Tests Parameters
104
105
* <p>
105
106
* Given : a pom.xml with sources and tests with a lot of parameters
106
107
* When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -110,7 +111,7 @@ public void testInvalidTestsDirectory() throws Exception {
110
111
public void testSourcesTestsParameters () throws Exception {
111
112
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
112
113
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/testSourcesTestsParams/" ), "test" );
113
- Assert . assertNotNull (utplsqlMojo );
114
+ assertNotNull (utplsqlMojo );
114
115
115
116
// TODO : move to another test about reporters
116
117
List <String > reporters = Whitebox .getInternalState (utplsqlMojo , "reporters" );
@@ -122,9 +123,9 @@ public void testSourcesTestsParameters() throws Exception {
122
123
assertEquals ("srcs/foo.sql" , sources .getFilePaths ().get (0 ));
123
124
assertEquals ("code_owner" , sources .getObjectOwner ());
124
125
assertEquals (".*/\\ w+/(\\ w+)/(\\ w+)\\ .\\ w{3}" , sources .getRegexPattern ());
125
- assertEquals (new Integer (9 ), sources .getNameSubExpression ());
126
- assertEquals (new Integer (1 ), sources .getTypeSubExpression ());
127
- assertEquals (new Integer (4 ), sources .getOwnerSubExpression ());
126
+ assertEquals (Integer . valueOf (9 ), sources .getNameSubExpression ());
127
+ assertEquals (Integer . valueOf (1 ), sources .getTypeSubExpression ());
128
+ assertEquals (Integer . valueOf (4 ), sources .getOwnerSubExpression ());
128
129
assertEquals (1 , sources .getTypeMappings ().size ());
129
130
assertEquals ("bar" , sources .getTypeMappings ().get (0 ).getKey ());
130
131
assertEquals ("foo" , sources .getTypeMappings ().get (0 ).getValue ());
@@ -136,16 +137,16 @@ public void testSourcesTestsParameters() throws Exception {
136
137
assertTrue (tests .getFilePaths ().contains ("te/st/spec.spc" ));
137
138
assertEquals ("tests_owner" , tests .getObjectOwner ());
138
139
assertEquals (".*/\\ w+/(\\ w+)/(\\ w+)\\ .\\ w{3}" , tests .getRegexPattern ());
139
- assertEquals (new Integer (54 ), tests .getNameSubExpression ());
140
- assertEquals (new Integer (21 ), tests .getTypeSubExpression ());
141
- assertEquals (new Integer (24 ), tests .getOwnerSubExpression ());
140
+ assertEquals (Integer . valueOf (54 ), tests .getNameSubExpression ());
141
+ assertEquals (Integer . valueOf (21 ), tests .getTypeSubExpression ());
142
+ assertEquals (Integer . valueOf (24 ), tests .getOwnerSubExpression ());
142
143
assertEquals (1 , tests .getTypeMappings ().size ());
143
144
assertEquals ("def" , tests .getTypeMappings ().get (0 ).getKey ());
144
145
assertEquals ("abc" , tests .getTypeMappings ().get (0 ).getValue ());
145
146
}
146
147
147
148
/**
148
- * testSourcesAndTestsParameterDoesNotExist.
149
+ * Sources and Tests Parameter does not exist
149
150
* <p>
150
151
* Given : a pom.xml with no sources / tests tags and default directory does not exist.
151
152
* When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -155,7 +156,7 @@ public void testSourcesTestsParameters() throws Exception {
155
156
public void testSourcesAndTestsParameterDoesNotExist () throws Exception {
156
157
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule .lookupConfiguredMojo (
157
158
new File ("src/test/resources/unit-tests/testNoSourcesTestsParams/directoryDoesNotExist/" ), "test" );
158
- Assert . assertNotNull (utplsqlMojo );
159
+ assertNotNull (utplsqlMojo );
159
160
160
161
// check sources
161
162
FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -167,7 +168,7 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
167
168
}
168
169
169
170
/**
170
- * testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists.
171
+ * Sources and Tests Parameter does not exist but Default Directory exists
171
172
* <p>
172
173
* Given : a pom.xml with no sources / tests tags but default directory exists.
173
174
* When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -177,7 +178,7 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
177
178
public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists () throws Exception {
178
179
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
179
180
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/testNoSourcesTestsParams/directoryExists/" ), "test" );
180
- Assert . assertNotNull (utplsqlMojo );
181
+ assertNotNull (utplsqlMojo );
181
182
182
183
// check sources
183
184
FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -193,7 +194,7 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
193
194
}
194
195
195
196
/**
196
- * testSourcesAndTestsParameterHaveNotDirectoryTag.
197
+ * Sources and Tests Parameter have not Directory Tag
197
198
* <p>
198
199
* Given : a pom.xml with source and test tag not containing a directory tag.
199
200
* When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -203,7 +204,7 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
203
204
public void testSourcesAndTestsParameterHaveNotDirectoryTag () throws Exception {
204
205
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
205
206
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/partialSourceAndTestTag/missingDirectory/" ), "test" );
206
- Assert . assertNotNull (utplsqlMojo );
207
+ assertNotNull (utplsqlMojo );
207
208
208
209
// check sources
209
210
FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -220,7 +221,7 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
220
221
}
221
222
222
223
/**
223
- * testSourcesAndTestsParameterHaveNotDirectoryTag.
224
+ * Sources and Tests Parameter have not Directory Tag
224
225
* <p>
225
226
* Given : a pom.xml with source and test tag not containing a directory tag.
226
227
* When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -230,7 +231,7 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
230
231
public void testSourcesAndTestsParameterHaveNotIncludesTag () throws Exception {
231
232
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
232
233
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/partialSourceAndTestTag/missingIncludes/" ), "test" );
233
- Assert . assertNotNull (utplsqlMojo );
234
+ assertNotNull (utplsqlMojo );
234
235
235
236
// check sources
236
237
FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -245,11 +246,14 @@ public void testSourcesAndTestsParameterHaveNotIncludesTag() throws Exception {
245
246
assertTrue (tests .getFilePaths ().contains ("src/test/bar/f2.pkg" ));
246
247
}
247
248
249
+ /**
250
+ * Default Console Behaviour
251
+ */
248
252
@ Test
249
253
public void testDefaultConsoleBehaviour () throws Exception {
250
254
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
251
255
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/defaultConsoleOutputBehaviour/" ), "test" );
252
- Assert . assertNotNull (utplsqlMojo );
256
+ assertNotNull (utplsqlMojo );
253
257
254
258
List <Reporter > reporterList = new ArrayList <>();
255
259
when (mockReporterFactory .createReporter (anyString ())).thenAnswer (invocation -> {
@@ -290,11 +294,14 @@ public void testDefaultConsoleBehaviour() throws Exception {
290
294
assertTrue (reporterParameter3 .isFileOutput ());
291
295
}
292
296
297
+ /**
298
+ * Add Default Reporter
299
+ */
293
300
@ Test
294
301
public void testAddDefaultReporter () throws Exception {
295
302
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
296
303
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/defaultConsoleOutputBehaviour/" ), "test" );
297
- Assert . assertNotNull (utplsqlMojo );
304
+ assertNotNull (utplsqlMojo );
298
305
299
306
List <Reporter > reporterList = new ArrayList <>();
300
307
when (mockReporterFactory .createReporter (anyString ())).thenAnswer (invocation -> {
@@ -314,11 +321,14 @@ public void testAddDefaultReporter() throws Exception {
314
321
verify (reporterList .get (0 )).init (mockConnection );
315
322
}
316
323
324
+ /**
325
+ * Skip utPLSQL Tests
326
+ */
317
327
@ Test
318
328
public void testSkipUtplsqlTests () throws Exception {
319
329
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
320
330
.lookupConfiguredMojo (new File ("src/test/resources/unit-tests/skipUtplsqlTests/" ), "test" );
321
- Assert . assertNotNull (utplsqlMojo );
331
+ assertNotNull (utplsqlMojo );
322
332
323
333
final ByteArrayOutputStream console = new ByteArrayOutputStream ();
324
334
System .setOut (new PrintStream (console ));
@@ -327,6 +337,6 @@ public void testSkipUtplsqlTests() throws Exception {
327
337
328
338
String standardOutput = console .toString ();
329
339
330
- Assert . assertTrue (standardOutput .contains ("utPLSQLTests are skipped." ));
340
+ assertTrue (standardOutput .contains ("utPLSQLTests are skipped." ));
331
341
}
332
342
}
0 commit comments