aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/musichub/business/PathValidation.java15
-rw-r--r--src/test/java/musichub/business/PathValidationTest.java22
2 files changed, 33 insertions, 4 deletions
diff --git a/src/main/java/musichub/business/PathValidation.java b/src/main/java/musichub/business/PathValidation.java
index 97f8759..b0281ba 100644
--- a/src/main/java/musichub/business/PathValidation.java
+++ b/src/main/java/musichub/business/PathValidation.java
@@ -11,10 +11,21 @@ import java.nio.file.Paths;
* @version 1.0
*/
-public class PathValidation {
+public final class PathValidation {
/**
- * Methode that checks the validity of a given path
+ * Method that just throws an AssertionError if the class is called
+ *
+ * @throws AssertionError you can't instantiate this class
+ * @author Aimeric ADJUTOR
+ */
+
+ public PathValidation() {
+ throw new AssertionError("You just can't instantiate this class.");
+ }
+
+ /**
+ * Method that checks the validity of a given path
*
* @param inputPath the path given by the user
* @return a boolean
diff --git a/src/test/java/musichub/business/PathValidationTest.java b/src/test/java/musichub/business/PathValidationTest.java
index 2b24d7a..fffbdde 100644
--- a/src/test/java/musichub/business/PathValidationTest.java
+++ b/src/test/java/musichub/business/PathValidationTest.java
@@ -1,8 +1,26 @@
package musichub.business;
+import org.junit.jupiter.api.Test;
+
+import static musichub.business.PathValidation.isPathValid;
+import static org.junit.jupiter.api.Assertions.*;
+
public class PathValidationTest {
+ @Test
void testIsPathValid() {
- //Not implemented yet
+ assertTrue(isPathValid("Song/Side_To_Side.wav")); //the right path
+ assertFalse(isPathValid("wrong_path/Side_To_Side.wav")); //wrong path
+ assertFalse(isPathValid("Song/Side_To_Side.mp3")); //wrong extension
+ }
+
+ @Test
+ void testPathValidationClass() {
+ try {
+ PathValidation pathValidationClass = new PathValidation();
+ } catch (Error ex) {
+ assertTrue(ex instanceof AssertionError);
+ assertEquals("You just can't instantiate this class.", ex.getMessage());
+ }
}
-} \ No newline at end of file
+}