diff options
author | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-06-27 12:43:28 +0200 |
---|---|---|
committer | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-06-27 12:43:28 +0200 |
commit | fa8c6e14b3f87407ea5805e35697acc4d93a8007 (patch) | |
tree | c5c8a6fc48d946e83109d446e3db9e60cb6557ca /src | |
parent | f9de1516a05f91e5632500a3b0a898938d6c795e (diff) |
PlayList class covered at 84%.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/java/musichub/business/PlayListTest.java | 54 | ||||
-rw-r--r-- | src/test/java/musichub/business/SongTest.java | 4 |
2 files changed, 56 insertions, 2 deletions
diff --git a/src/test/java/musichub/business/PlayListTest.java b/src/test/java/musichub/business/PlayListTest.java new file mode 100644 index 0000000..9fe63cf --- /dev/null +++ b/src/test/java/musichub/business/PlayListTest.java @@ -0,0 +1,54 @@ +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; + +import java.util.ArrayList; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.*; + +public class PlayListTest { + final String DIR = System.getProperty("user.dir"); + final String PLAYLISTS_FILE_PATH = DIR + "/files/playlists.xml"; + final XMLHandler xmlHandler = new XMLHandler(); + String title = "Side To Side"; + String id = "66d277ca-cbc4-471c-a07e-082363375bcc"; + ArrayList<UUID> elementUUIDs = null; + + @Test + void testPlaylistClass() { + new PlayList(title, id, elementUUIDs); + new PlayList(title); + + } + + @Test + void testPlaylistClassXML() { + NodeList playlistNodes = xmlHandler.parseXMLFile(PLAYLISTS_FILE_PATH); + Element playlistElement = (Element) playlistNodes.item(1); + new PlayList(playlistElement); + } + + @Test + void testGetElements() { + assertNull(new PlayList(title, id, elementUUIDs).getElements()); + } + + @Test + void testGetTitle() { + assertEquals(new PlayList(title).getTitle(), "Side To Side"); + assertNotEquals(new PlayList(title).getTitle(), "God Is A Woman"); + } + + @Test + void testCreateXMLElement() { + PlayList p = new PlayList(title); + Document document = xmlHandler.createXMLDocument(); + Element root = document.createElement("playlists"); + p.createXMLElement(document, root); + } +} diff --git a/src/test/java/musichub/business/SongTest.java b/src/test/java/musichub/business/SongTest.java index 7022786..14f9af1 100644 --- a/src/test/java/musichub/business/SongTest.java +++ b/src/test/java/musichub/business/SongTest.java @@ -23,14 +23,14 @@ public class SongTest { @Test - void testSongClasses() { + void testSongClass() { new Song(title, artist, length, uid, content, genre); new Song(title, artist, length, content, genre); } @Test - void testSongXml() { + void testSongClassXML() { NodeList audioelementsNodes = xmlHandler.parseXMLFile(ELEMENTS_FILE_PATH); Element audioElement = (Element) audioelementsNodes.item(1); new Song(audioElement); |