aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/musichub/business
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-06-27 12:12:56 +0200
committerClyhtsuriva <aimeric@adjutor.xyz>2021-06-27 12:12:56 +0200
commitf9de1516a05f91e5632500a3b0a898938d6c795e (patch)
tree3658a35977b2019da078f650bafc56820d41e6eb /src/test/java/musichub/business
parenta9f46e2164f0d9ce416f34ebcb68d532de98cdb2 (diff)
Song class fully covered.
Diffstat (limited to 'src/test/java/musichub/business')
-rw-r--r--src/test/java/musichub/business/SongTest.java55
1 files changed, 46 insertions, 9 deletions
diff --git a/src/test/java/musichub/business/SongTest.java b/src/test/java/musichub/business/SongTest.java
index b25b6d2..7022786 100644
--- a/src/test/java/musichub/business/SongTest.java
+++ b/src/test/java/musichub/business/SongTest.java
@@ -2,6 +2,7 @@ package musichub.business;
import musichub.util.XMLHandler;
import org.junit.jupiter.api.Test;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -16,31 +17,67 @@ public class SongTest {
String content = "Song/Side_To_Side.wav";
String genre = "rock";
+ final String DIR = System.getProperty("user.dir");
+ final String ELEMENTS_FILE_PATH = DIR + "/files/elements.xml";
+ final XMLHandler xmlHandler = new XMLHandler();
+
+
@Test
void testSongClasses() {
- Song song_uuid = new Song(title, artist, length, uid, content, genre);
- Song song = new Song(title, artist, length, content, genre);
+ new Song(title, artist, length, uid, content, genre);
+ new Song(title, artist, length, content, genre);
}
@Test
void testSongXml() {
- final String DIR = System.getProperty("user.dir");
- final String ELEMENTS_FILE_PATH = DIR + "/files/elements.xml";
- final XMLHandler xmlHandler = new XMLHandler();
NodeList audioelementsNodes = xmlHandler.parseXMLFile(ELEMENTS_FILE_PATH);
Element audioElement = (Element) audioelementsNodes.item(1);
- Song song_xml = new Song(audioElement);
+ new Song(audioElement);
}
@Test
void testGetGenre() {
- assertEquals(new Song(title, artist, length, content, genre).getGenre(), "rock");
- assertNotEquals(new Song(title, artist, length, content, genre).getGenre(), "pop");
+ assertEquals(new Song(title, artist, length, content, genre)
+ .getGenre(),
+ "rock");
+ assertNotEquals(new Song(title, artist, length, content, genre)
+ .getGenre(),
+ "pop");
}
@Test
void testSetGenre() {
- // Not Implemented Yet
+ new Song(title, artist, length, content, "classic");
+ new Song(title, artist, length, content, "hiphop");
+ new Song(title, artist, length, content, "rock");
+ new Song(title, artist, length, content, "pop");
+ new Song(title, artist, length, content, "rap");
+
+ Song s = new Song(title, artist, length, content, "cgfdhdfhj");
+ assertEquals(s.getGenre(), "jazz");
+ }
+
+ @Test
+ void testToString() {
+ assertEquals(
+ new Song(title, artist, length, content, genre)
+ .toString(),
+ "Title = Side To Side, Artist = Ariana Grande, Length = 186, Content = Song/Side_To_Side.wav, Genre = rock\n"
+ );
+ assertNotEquals(
+ new Song(title, artist, length, content, genre)
+ .toString(),
+ "Title = God is a woman, Artist = Ariana Grande, Length = 186, Content = Song/Side_To_Side.wav, Genre = rock\n"
+ );
+ }
+
+ @Test
+ void testCreateXMLElement() {
+ Song s = new Song(title, artist, length, content, genre);
+ Document document = xmlHandler.createXMLDocument();
+ Element root = document.createElement("elements");
+ s.createXMLElement(document, root);
+
}
}