33import org .apache .commons .lang3 .tuple .Pair ;
44import org .apache .maven .plugin .MojoExecutionException ;
55import org .apache .maven .plugin .testing .MojoRule ;
6- import org .junit .Assert ;
76import org .junit .Before ;
87import org .junit .Rule ;
98import org .junit .Test ;
2928
3029import static org .junit .Assert .assertEquals ;
3130import static org .junit .Assert .assertFalse ;
31+ import static org .junit .Assert .assertNotNull ;
32+ import static org .junit .Assert .assertThrows ;
3233import static org .junit .Assert .assertTrue ;
3334import static org .mockito .ArgumentMatchers .anyString ;
3435import static org .mockito .Mockito .mock ;
@@ -64,7 +65,7 @@ public void setUp() throws Exception {
6465 }
6566
6667 /**
67- * testInvalidSourcesDirectory.
68+ * Invalid Sources Directory
6869 * <p>
6970 * Given : a pom.xml with invalid sources' directory
7071 * When : pom is read and buildSourcesOptions is run
@@ -74,15 +75,15 @@ public void setUp() throws Exception {
7475 public void testInvalidSourcesDirectory () throws Exception {
7576 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
7677 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/invalidTestsSourcesDirectories/" ), "test" );
77- Assert . assertNotNull (utplsqlMojo );
78+ assertNotNull (utplsqlMojo );
7879
79- MojoExecutionException exception = Assert . assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" ));
80+ MojoExecutionException exception = assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" ));
8081
81- Assert . assertEquals ("Invalid <SOURCES> in your pom.xml" , exception .getMessage ());
82+ assertEquals ("Invalid <SOURCES> in your pom.xml" , exception .getMessage ());
8283 }
8384
8485 /**
85- * testInvalidTestsDirectory.
86+ * Invalid Tests Directory
8687 * <p>
8788 * Given : a pom.xml with invalid tests' directory
8889 * When : pom is read and buildTestsOptions is run
@@ -92,15 +93,15 @@ public void testInvalidSourcesDirectory() throws Exception {
9293 public void testInvalidTestsDirectory () throws Exception {
9394 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
9495 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/invalidTestsSourcesDirectories/" ), "test" );
95- Assert . assertNotNull (utplsqlMojo );
96+ assertNotNull (utplsqlMojo );
9697
97- MojoExecutionException exception = Assert . assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildTestsOptions" ));
98+ MojoExecutionException exception = assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildTestsOptions" ));
9899
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 ());
100101 }
101102
102103 /**
103- * testSourcesTestsParameters.
104+ * Sources Tests Parameters
104105 * <p>
105106 * Given : a pom.xml with sources and tests with a lot of parameters
106107 * When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -110,7 +111,7 @@ public void testInvalidTestsDirectory() throws Exception {
110111 public void testSourcesTestsParameters () throws Exception {
111112 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
112113 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/testSourcesTestsParams/" ), "test" );
113- Assert . assertNotNull (utplsqlMojo );
114+ assertNotNull (utplsqlMojo );
114115
115116 // TODO : move to another test about reporters
116117 List <String > reporters = Whitebox .getInternalState (utplsqlMojo , "reporters" );
@@ -122,9 +123,9 @@ public void testSourcesTestsParameters() throws Exception {
122123 assertEquals ("srcs/foo.sql" , sources .getFilePaths ().get (0 ));
123124 assertEquals ("code_owner" , sources .getObjectOwner ());
124125 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 ());
128129 assertEquals (1 , sources .getTypeMappings ().size ());
129130 assertEquals ("bar" , sources .getTypeMappings ().get (0 ).getKey ());
130131 assertEquals ("foo" , sources .getTypeMappings ().get (0 ).getValue ());
@@ -136,16 +137,16 @@ public void testSourcesTestsParameters() throws Exception {
136137 assertTrue (tests .getFilePaths ().contains ("te/st/spec.spc" ));
137138 assertEquals ("tests_owner" , tests .getObjectOwner ());
138139 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 ());
142143 assertEquals (1 , tests .getTypeMappings ().size ());
143144 assertEquals ("def" , tests .getTypeMappings ().get (0 ).getKey ());
144145 assertEquals ("abc" , tests .getTypeMappings ().get (0 ).getValue ());
145146 }
146147
147148 /**
148- * testSourcesAndTestsParameterDoesNotExist.
149+ * Sources and Tests Parameter does not exist
149150 * <p>
150151 * Given : a pom.xml with no sources / tests tags and default directory does not exist.
151152 * When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -155,7 +156,7 @@ public void testSourcesTestsParameters() throws Exception {
155156 public void testSourcesAndTestsParameterDoesNotExist () throws Exception {
156157 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule .lookupConfiguredMojo (
157158 new File ("src/test/resources/unit-tests/testNoSourcesTestsParams/directoryDoesNotExist/" ), "test" );
158- Assert . assertNotNull (utplsqlMojo );
159+ assertNotNull (utplsqlMojo );
159160
160161 // check sources
161162 FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -167,7 +168,7 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
167168 }
168169
169170 /**
170- * testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists.
171+ * Sources and Tests Parameter does not exist but Default Directory exists
171172 * <p>
172173 * Given : a pom.xml with no sources / tests tags but default directory exists.
173174 * When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -177,7 +178,7 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
177178 public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists () throws Exception {
178179 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
179180 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/testNoSourcesTestsParams/directoryExists/" ), "test" );
180- Assert . assertNotNull (utplsqlMojo );
181+ assertNotNull (utplsqlMojo );
181182
182183 // check sources
183184 FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -193,7 +194,7 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
193194 }
194195
195196 /**
196- * testSourcesAndTestsParameterHaveNotDirectoryTag.
197+ * Sources and Tests Parameter have not Directory Tag
197198 * <p>
198199 * Given : a pom.xml with source and test tag not containing a directory tag.
199200 * When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -203,7 +204,7 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
203204 public void testSourcesAndTestsParameterHaveNotDirectoryTag () throws Exception {
204205 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
205206 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/partialSourceAndTestTag/missingDirectory/" ), "test" );
206- Assert . assertNotNull (utplsqlMojo );
207+ assertNotNull (utplsqlMojo );
207208
208209 // check sources
209210 FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -220,7 +221,7 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
220221 }
221222
222223 /**
223- * testSourcesAndTestsParameterHaveNotDirectoryTag.
224+ * Sources and Tests Parameter have not Directory Tag
224225 * <p>
225226 * Given : a pom.xml with source and test tag not containing a directory tag.
226227 * When : pom is read and buildSourcesOptions / buildTestsOptions are run
@@ -230,7 +231,7 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
230231 public void testSourcesAndTestsParameterHaveNotIncludesTag () throws Exception {
231232 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
232233 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/partialSourceAndTestTag/missingIncludes/" ), "test" );
233- Assert . assertNotNull (utplsqlMojo );
234+ assertNotNull (utplsqlMojo );
234235
235236 // check sources
236237 FileMapperOptions sources = Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" );
@@ -245,11 +246,14 @@ public void testSourcesAndTestsParameterHaveNotIncludesTag() throws Exception {
245246 assertTrue (tests .getFilePaths ().contains ("src/test/bar/f2.pkg" ));
246247 }
247248
249+ /**
250+ * Default Console Behaviour
251+ */
248252 @ Test
249253 public void testDefaultConsoleBehaviour () throws Exception {
250254 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
251255 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/defaultConsoleOutputBehaviour/" ), "test" );
252- Assert . assertNotNull (utplsqlMojo );
256+ assertNotNull (utplsqlMojo );
253257
254258 List <Reporter > reporterList = new ArrayList <>();
255259 when (mockReporterFactory .createReporter (anyString ())).thenAnswer (invocation -> {
@@ -290,11 +294,14 @@ public void testDefaultConsoleBehaviour() throws Exception {
290294 assertTrue (reporterParameter3 .isFileOutput ());
291295 }
292296
297+ /**
298+ * Add Default Reporter
299+ */
293300 @ Test
294301 public void testAddDefaultReporter () throws Exception {
295302 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
296303 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/defaultConsoleOutputBehaviour/" ), "test" );
297- Assert . assertNotNull (utplsqlMojo );
304+ assertNotNull (utplsqlMojo );
298305
299306 List <Reporter > reporterList = new ArrayList <>();
300307 when (mockReporterFactory .createReporter (anyString ())).thenAnswer (invocation -> {
@@ -314,11 +321,14 @@ public void testAddDefaultReporter() throws Exception {
314321 verify (reporterList .get (0 )).init (mockConnection );
315322 }
316323
324+ /**
325+ * Skip utPLSQL Tests
326+ */
317327 @ Test
318328 public void testSkipUtplsqlTests () throws Exception {
319329 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
320330 .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/skipUtplsqlTests/" ), "test" );
321- Assert . assertNotNull (utplsqlMojo );
331+ assertNotNull (utplsqlMojo );
322332
323333 final ByteArrayOutputStream console = new ByteArrayOutputStream ();
324334 System .setOut (new PrintStream (console ));
@@ -327,6 +337,6 @@ public void testSkipUtplsqlTests() throws Exception {
327337
328338 String standardOutput = console .toString ();
329339
330- Assert . assertTrue (standardOutput .contains ("utPLSQLTests are skipped." ));
340+ assertTrue (standardOutput .contains ("utPLSQLTests are skipped." ));
331341 }
332342}
0 commit comments