4848 * ...
4949 * </pre>
5050 */
51- public class PathUtils {
51+ public final class PathUtils {
5252
5353 private PathUtils () {
5454 throw new AssertionError ("PathUtils is a static utility class that cannot be instantiated" );
@@ -57,6 +57,9 @@ private PathUtils() {
5757 private static final String SUREFIRE_PATH = "surefire-reports" ;
5858 private static final String FAILSAFE_PATH = "failsafe-reports" ;
5959
60+ /**
61+ * This enumeration contains methods to help build proxy subclass names and select reports directories.
62+ */
6063 public enum ReportsDirectory {
6164
6265 SUREFIRE_1 ("(Test)(.*)" , SUREFIRE_PATH ),
@@ -76,37 +79,65 @@ public enum ReportsDirectory {
7679 this .folder = folder ;
7780 }
7881
82+ /**
83+ * Get the regular expression that matches class names for this constant.
84+ *
85+ * @return class-matching regular expression string
86+ */
7987 public String getRegEx () {
8088 return regex ;
8189 }
8290
91+ /**
92+ * Get the name of the folder associated with this constant.
93+ *
94+ * @return class-related folder name
95+ */
8396 public String getFolder () {
8497 return folder ;
8598 }
8699
100+ /**
101+ * Get the resolved Maven-derived path associated with this constant.
102+ *
103+ * @return Maven folder path
104+ */
87105 public Path getPath () {
88106 return getTargetPath ().resolve (folder );
89107 }
90108
109+ /**
110+ * Get the reports directory constant for the specified test class object.
111+ *
112+ * @param obj test class object
113+ * @return reports directory constant
114+ */
91115 public static ReportsDirectory fromObject (Object obj ) {
92116 String name = obj .getClass ().getSimpleName ();
93117 for (ReportsDirectory constant : values ()) {
94118 if (name .matches (constant .regex )) {
95119 return constant ;
96120 }
97121 }
98- return null ;
122+ throw new IllegalStateException ( "Someone removed the 'default' pattern from this enumeration" ) ;
99123 }
100124
125+ /**
126+ * Get reports directory path for the specified test class object.
127+ *
128+ * @param obj test class object
129+ * @return reports directory path
130+ */
101131 public static Path getPathForObject (Object obj ) {
102132 ReportsDirectory constant = fromObject (obj );
103- Path path = getTargetPath ();
104- if (constant != null ) {
105- path = path .resolve (constant .folder );
106- }
107- return path ;
133+ return getTargetPath ().resolve (constant .folder );
108134 }
109135
136+ /**
137+ * Get the path for the 'target' folder of the current project.
138+ *
139+ * @return path for project 'target' folder
140+ */
110141 private static Path getTargetPath () {
111142 return Paths .get (getBaseDir (), "target" );
112143 }
0 commit comments