1- package org .utplsql .maven .plugin . test ;
1+ package org .utplsql .maven .plugin ;
22
33import org .apache .commons .lang3 .tuple .Pair ;
44import org .apache .maven .plugin .MojoExecutionException ;
@@ -47,9 +47,6 @@ public class UtPLSQLMojoTest {
4747 @ Rule
4848 public MojoRule rule = new MojoRule ();
4949
50- @ Rule
51- public ExpectedException thrown = ExpectedException .none ();
52-
5350 @ Mock
5451 public Connection mockConnection ;
5552
@@ -71,54 +68,50 @@ public void setUp() throws Exception {
7168 /**
7269 * testInvalidSourcesDirectory.
7370 * <p>
74- * Given : a pom.xml with invalid sources' directory When : pom is read and
75- * buildSourcesOptions is run Then : it should throw a MojoExecutionException
71+ * Given : a pom.xml with invalid sources' directory
72+ * When : pom is read andbuildSourcesOptions is run
73+ * Then : it should throw a MojoExecutionException
7674 */
7775 @ Test
7876 public void testInvalidSourcesDirectory () throws Exception {
7977 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
80- .lookupConfiguredMojo (new File ("src/test/resources/invalidTestsSourcesDirectories/" ), "test" );
78+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ invalidTestsSourcesDirectories/" ), "test" );
8179 Assert .assertNotNull (utplsqlMojo );
8280
83- // Expected exception
84- thrown .expect (MojoExecutionException .class );
85- // Excepted message
86- thrown .expectMessage ("Invalid <SOURCES> in your pom.xml" );
81+ MojoExecutionException exception = Assert .assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildSourcesOptions" ));
8782
88- Whitebox . invokeMethod ( utplsqlMojo , "buildSourcesOptions" );
83+ Assert . assertEquals ( "Invalid <SOURCES> in your pom.xml" , exception . getMessage () );
8984 }
9085
9186 /**
9287 * testInvalidTestsDirectory.
9388 * <p>
94- * Given : a pom.xml with invalid tests' directory When : pom is read and
95- * buildTestsOptions is run Then : it should throw a MojoExecutionException
89+ * Given : a pom.xml with invalid tests' directory
90+ * When : pom is read and buildTestsOptions is run
91+ * Then : it should throw a MojoExecutionException
9692 */
9793 @ Test
9894 public void testInvalidTestsDirectory () throws Exception {
9995 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
100- .lookupConfiguredMojo (new File ("src/test/resources/invalidTestsSourcesDirectories/" ), "test" );
96+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ invalidTestsSourcesDirectories/" ), "test" );
10197 Assert .assertNotNull (utplsqlMojo );
10298
103- // Expected exception
104- thrown .expect (MojoExecutionException .class );
105- // Excepted message
106- thrown .expectMessage ("Invalid <TESTS> in your pom.xml" );
99+ MojoExecutionException exception = Assert .assertThrows (MojoExecutionException .class , () -> Whitebox .invokeMethod (utplsqlMojo , "buildTestsOptions" ));
107100
108- Whitebox . invokeMethod ( utplsqlMojo , "buildTestsOptions" );
101+ Assert . assertEquals ( "Invalid <TESTS> in your pom.xml: Invalid <directory> bar in resource. Check your pom.xml" , exception . getMessage () );
109102 }
110103
111104 /**
112105 * testSourcesTestsParameters.
113106 * <p>
114- * Given : a pom.xml with sources and tests with a lot of parameters When : pom
115- * is read and buildSourcesOptions / buildTestsOptions are run Then : it should
116- * fill all parameters correctly
107+ * Given : a pom.xml with sources and tests with a lot of parameters
108+ * When : pom is read and buildSourcesOptions / buildTestsOptions are run
109+ * Then : it should fill all parameters correctly
117110 */
118111 @ Test
119112 public void testSourcesTestsParameters () throws Exception {
120113 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
121- .lookupConfiguredMojo (new File ("src/test/resources/testSourcesTestsParams/" ), "test" );
114+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ testSourcesTestsParams/" ), "test" );
122115 Assert .assertNotNull (utplsqlMojo );
123116
124117 // TODO : move to another test about reporters
@@ -156,14 +149,14 @@ public void testSourcesTestsParameters() throws Exception {
156149 /**
157150 * testSourcesAndTestsParameterDoesNotExist.
158151 * <p>
159- * Given : a pom.xml with no sources / tests tags and default directory does not
160- * exist. When : pom is read and buildSourcesOptions / buildTestsOptions are run
152+ * Given : a pom.xml with no sources / tests tags and default directory does not exist.
153+ * When : pom is read and buildSourcesOptions / buildTestsOptions are run
161154 * Then : it should not find any source files
162155 */
163156 @ Test
164157 public void testSourcesAndTestsParameterDoesNotExist () throws Exception {
165158 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule .lookupConfiguredMojo (
166- new File ("src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/" ), "test" );
159+ new File ("src/test/resources/unit-tests/ testNoSourcesTestsParams/directoryDoesNotExist/" ), "test" );
167160 Assert .assertNotNull (utplsqlMojo );
168161
169162 // check sources
@@ -179,13 +172,13 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
179172 * testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists.
180173 * <p>
181174 * Given : a pom.xml with no sources / tests tags but default directory exists.
182- * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
183- * it should find all sources/tests files in default directories
175+ * When : pom is read and buildSourcesOptions / buildTestsOptions are run
176+ * Then : it should find all sources/tests files in default directories
184177 */
185178 @ Test
186179 public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists () throws Exception {
187180 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
188- .lookupConfiguredMojo (new File ("src/test/resources/testNoSourcesTestsParams/directoryExists/" ), "test" );
181+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ testNoSourcesTestsParams/directoryExists/" ), "test" );
189182 Assert .assertNotNull (utplsqlMojo );
190183
191184 // check sources
@@ -205,13 +198,13 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
205198 * testSourcesAndTestsParameterHaveNotDirectoryTag.
206199 * <p>
207200 * Given : a pom.xml with source and test tag not containing a directory tag.
208- * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
209- * it should find all sources/tests files in default directories
201+ * When : pom is read and buildSourcesOptions / buildTestsOptions are run
202+ * Then : it should find all sources/tests files in default directories
210203 */
211204 @ Test
212205 public void testSourcesAndTestsParameterHaveNotDirectoryTag () throws Exception {
213206 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
214- .lookupConfiguredMojo (new File ("src/test/resources/partialSourceAndTestTag/missingDirectory/" ), "test" );
207+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ partialSourceAndTestTag/missingDirectory/" ), "test" );
215208 Assert .assertNotNull (utplsqlMojo );
216209
217210 // check sources
@@ -232,13 +225,13 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
232225 * testSourcesAndTestsParameterHaveNotDirectoryTag.
233226 * <p>
234227 * Given : a pom.xml with source and test tag not containing a directory tag.
235- * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
236- * it should find all sources/tests files in default directories
228+ * When : pom is read and buildSourcesOptions / buildTestsOptions are run
229+ * Then : it should find all sources/tests files in default directories
237230 */
238231 @ Test
239232 public void testSourcesAndTestsParameterHaveNotIncludesTag () throws Exception {
240233 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
241- .lookupConfiguredMojo (new File ("src/test/resources/partialSourceAndTestTag/missingIncludes/" ), "test" );
234+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ partialSourceAndTestTag/missingIncludes/" ), "test" );
242235 Assert .assertNotNull (utplsqlMojo );
243236
244237 // check sources
@@ -257,7 +250,7 @@ public void testSourcesAndTestsParameterHaveNotIncludesTag() throws Exception {
257250 @ Test
258251 public void testDefaultConsoleBehaviour () throws Exception {
259252 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
260- .lookupConfiguredMojo (new File ("src/test/resources/defaultConsoleOutputBehaviour/" ), "test" );
253+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ defaultConsoleOutputBehaviour/" ), "test" );
261254 Assert .assertNotNull (utplsqlMojo );
262255
263256 List <Reporter > reporterList = new ArrayList <>();
@@ -302,7 +295,7 @@ public void testDefaultConsoleBehaviour() throws Exception {
302295 @ Test
303296 public void testAddDefaultReporter () throws Exception {
304297 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
305- .lookupConfiguredMojo (new File ("src/test/resources/defaultConsoleOutputBehaviour/" ), "test" );
298+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ defaultConsoleOutputBehaviour/" ), "test" );
306299 Assert .assertNotNull (utplsqlMojo );
307300
308301 List <Reporter > reporterList = new ArrayList <>();
@@ -326,7 +319,7 @@ public void testAddDefaultReporter() throws Exception {
326319 @ Test
327320 public void testSkipUtplsqlTests () throws Exception {
328321 UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo ) rule
329- .lookupConfiguredMojo (new File ("src/test/resources/skipUtplsqlTests/" ), "test" );
322+ .lookupConfiguredMojo (new File ("src/test/resources/unit-tests/ skipUtplsqlTests/" ), "test" );
330323 Assert .assertNotNull (utplsqlMojo );
331324
332325 final ByteArrayOutputStream console = new ByteArrayOutputStream ();
0 commit comments