From e9ee951e570c441151385d1ccd8c4230abf704ca Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Sat, 26 Jun 2021 14:32:12 +0200 Subject: Updated javadoc, added jacoco and the necessary JUnit for this feature. --- target/site/jacoco/musichub.business/Album.html | 1 + .../site/jacoco/musichub.business/Album.java.html | 146 +++++++++ .../site/jacoco/musichub.business/AudioBook.html | 1 + .../jacoco/musichub.business/AudioBook.java.html | 79 +++++ .../jacoco/musichub.business/AudioElement.html | 1 + .../musichub.business/AudioElement.java.html | 133 ++++++++ target/site/jacoco/musichub.business/Category.html | 1 + .../jacoco/musichub.business/Category.java.html | 15 + target/site/jacoco/musichub.business/Genre.html | 1 + .../site/jacoco/musichub.business/Genre.java.html | 15 + target/site/jacoco/musichub.business/Language.html | 1 + .../jacoco/musichub.business/Language.java.html | 15 + target/site/jacoco/musichub.business/MusicHub.html | 1 + .../jacoco/musichub.business/MusicHub.java.html | 343 +++++++++++++++++++++ .../musichub.business/NoAlbumFoundException.html | 1 + .../NoAlbumFoundException.java.html | 9 + .../musichub.business/NoElementFoundException.html | 1 + .../NoElementFoundException.java.html | 9 + .../NoPlayListFoundException.html | 1 + .../NoPlayListFoundException.java.html | 9 + .../jacoco/musichub.business/PathValidation.html | 1 + .../musichub.business/PathValidation.java.html | 39 +++ target/site/jacoco/musichub.business/PlayList.html | 1 + .../jacoco/musichub.business/PlayList.java.html | 101 ++++++ target/site/jacoco/musichub.business/Song.html | 1 + .../site/jacoco/musichub.business/Song.java.html | 59 ++++ .../jacoco/musichub.business/SortByAuthor.html | 1 + .../site/jacoco/musichub.business/SortByDate.html | 1 + .../site/jacoco/musichub.business/SortByGenre.html | 1 + target/site/jacoco/musichub.business/index.html | 1 + .../jacoco/musichub.business/index.source.html | 1 + 31 files changed, 990 insertions(+) create mode 100644 target/site/jacoco/musichub.business/Album.html create mode 100644 target/site/jacoco/musichub.business/Album.java.html create mode 100644 target/site/jacoco/musichub.business/AudioBook.html create mode 100644 target/site/jacoco/musichub.business/AudioBook.java.html create mode 100644 target/site/jacoco/musichub.business/AudioElement.html create mode 100644 target/site/jacoco/musichub.business/AudioElement.java.html create mode 100644 target/site/jacoco/musichub.business/Category.html create mode 100644 target/site/jacoco/musichub.business/Category.java.html create mode 100644 target/site/jacoco/musichub.business/Genre.html create mode 100644 target/site/jacoco/musichub.business/Genre.java.html create mode 100644 target/site/jacoco/musichub.business/Language.html create mode 100644 target/site/jacoco/musichub.business/Language.java.html create mode 100644 target/site/jacoco/musichub.business/MusicHub.html create mode 100644 target/site/jacoco/musichub.business/MusicHub.java.html create mode 100644 target/site/jacoco/musichub.business/NoAlbumFoundException.html create mode 100644 target/site/jacoco/musichub.business/NoAlbumFoundException.java.html create mode 100644 target/site/jacoco/musichub.business/NoElementFoundException.html create mode 100644 target/site/jacoco/musichub.business/NoElementFoundException.java.html create mode 100644 target/site/jacoco/musichub.business/NoPlayListFoundException.html create mode 100644 target/site/jacoco/musichub.business/NoPlayListFoundException.java.html create mode 100644 target/site/jacoco/musichub.business/PathValidation.html create mode 100644 target/site/jacoco/musichub.business/PathValidation.java.html create mode 100644 target/site/jacoco/musichub.business/PlayList.html create mode 100644 target/site/jacoco/musichub.business/PlayList.java.html create mode 100644 target/site/jacoco/musichub.business/Song.html create mode 100644 target/site/jacoco/musichub.business/Song.java.html create mode 100644 target/site/jacoco/musichub.business/SortByAuthor.html create mode 100644 target/site/jacoco/musichub.business/SortByDate.html create mode 100644 target/site/jacoco/musichub.business/SortByGenre.html create mode 100644 target/site/jacoco/musichub.business/index.html create mode 100644 target/site/jacoco/musichub.business/index.source.html (limited to 'target/site/jacoco/musichub.business') diff --git a/target/site/jacoco/musichub.business/Album.html b/target/site/jacoco/musichub.business/Album.html new file mode 100644 index 0000000..24287ce --- /dev/null +++ b/target/site/jacoco/musichub.business/Album.html @@ -0,0 +1 @@ +Album

Album

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total330 of 3300 %14 of 140 %1616848499
createXMLElement(Document, Element)1290 %20 %22262611
Album(Element)1120 %120 %77262611
Album(String, String, int, String)340 %n/a11121211
Album(String, String, int, String, String, ArrayList)330 %n/a11121211
getSongsRandomly()70 %n/a113311
addSong(UUID)60 %n/a112211
getSongs()30 %n/a111111
getTitle()30 %n/a111111
getDate()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Album.java.html b/target/site/jacoco/musichub.business/Album.java.html new file mode 100644 index 0000000..107bbe9 --- /dev/null +++ b/target/site/jacoco/musichub.business/Album.java.html @@ -0,0 +1,146 @@ +Album.java

Album.java

package musichub.business;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+public class Album {
+    private final String title;
+    private final int lengthInSeconds;
+    private final UUID uuid;
+    private String artist;
+    private Date date;
+    private ArrayList<UUID> songsUIDs;
+
+    public Album(String title, String artist, int lengthInSeconds, String id, String date, ArrayList<UUID> songsUIDs) {
+        this.title = title;
+        this.artist = artist;
+        this.lengthInSeconds = lengthInSeconds;
+        this.uuid = UUID.fromString(id);
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            this.date = sdf.parse(date);
+        } catch (ParseException ex) {
+            ex.printStackTrace();
+        }
+        this.songsUIDs = songsUIDs;
+    }
+
+    public Album(String title, String artist, int lengthInSeconds, String date) {
+        this.title = title;
+        this.artist = artist;
+        this.lengthInSeconds = lengthInSeconds;
+        this.uuid = UUID.randomUUID();
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            this.date = sdf.parse(date);
+        } catch (ParseException ex) {
+            ex.printStackTrace();
+        }
+        this.songsUIDs = new ArrayList<>();
+    }
+
+    public Album(Element xmlElement) throws Exception {
+        {
+            this.title = xmlElement.getElementsByTagName("title").item(0).getTextContent();
+            this.lengthInSeconds = Integer.parseInt(xmlElement.getElementsByTagName("lengthInSeconds").item(0).getTextContent());
+            String uuid = null;
+            try {
+                uuid = xmlElement.getElementsByTagName("UUID").item(0).getTextContent();
+            } catch (Exception ex) {
+                System.out.println("Empty album UUID, will create a new one");
+            }
+            if ((uuid == null) || (uuid.isEmpty()))
+                this.uuid = UUID.randomUUID();
+            else this.uuid = UUID.fromString(uuid);
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            this.date = sdf.parse(xmlElement.getElementsByTagName("date").item(0).getTextContent());
+            //parse list of songs:
+            Node songsElement = xmlElement.getElementsByTagName("songs").item(0);
+            NodeList songUUIDNodes = songsElement.getChildNodes();
+            if (songUUIDNodes == null) return;
+
+            this.songsUIDs = new ArrayList<>();
+
+            for (int i = 0; i < songUUIDNodes.getLength(); i++) {
+                if (songUUIDNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
+                    Element songElement = (Element) songUUIDNodes.item(i);
+                    if (songElement.getNodeName().equals("UUID")) {
+                        try {
+                            this.addSong(UUID.fromString(songElement.getTextContent()));
+                        } catch (Exception ex) {
+                            ex.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    public void addSong(UUID song) {
+        songsUIDs.add(song);
+    }
+
+
+    public List<UUID> getSongs() {
+        return songsUIDs;
+    }
+
+    public ArrayList<UUID> getSongsRandomly() {
+        ArrayList<UUID> shuffledSongs = songsUIDs;
+        Collections.shuffle(shuffledSongs);
+        return shuffledSongs;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void createXMLElement(Document document, Element parentElement) {
+        Element albumElement = document.createElement("album");
+        parentElement.appendChild(albumElement);
+
+        Element nameElement = document.createElement("title");
+        nameElement.appendChild(document.createTextNode(title));
+        albumElement.appendChild(nameElement);
+
+        Element artistElement = document.createElement("artist");
+        artistElement.appendChild(document.createTextNode(artist));
+        albumElement.appendChild(artistElement);
+
+        Element lengthElement = document.createElement("lengthInSeconds");
+        lengthElement.appendChild(document.createTextNode(Integer.valueOf(lengthInSeconds).toString()));
+        albumElement.appendChild(lengthElement);
+
+        Element UUIDElement = document.createElement("UUID");
+        UUIDElement.appendChild(document.createTextNode(uuid.toString()));
+        albumElement.appendChild(UUIDElement);
+
+        Element dateElement = document.createElement("date");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        dateElement.appendChild(document.createTextNode(sdf.format(date)));
+        albumElement.appendChild(dateElement);
+
+        Element songsElement = document.createElement("songs");
+        for (UUID currentUUID : this.songsUIDs) {
+            Element songUUIDElement = document.createElement("UUID");
+            songUUIDElement.appendChild(document.createTextNode(currentUUID.toString()));
+            songsElement.appendChild(songUUIDElement);
+        }
+        albumElement.appendChild(songsElement);
+
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/AudioBook.html b/target/site/jacoco/musichub.business/AudioBook.html new file mode 100644 index 0000000..aec1e56 --- /dev/null +++ b/target/site/jacoco/musichub.business/AudioBook.html @@ -0,0 +1 @@ +AudioBook

AudioBook

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total164 of 1640 %10 of 100 %1717393999
createXMLElement(Document, Element)450 %n/a11101011
setLanguage(String)290 %50 %557711
setCategory(String)290 %50 %557711
AudioBook(Element)200 %n/a114411
AudioBook(String, String, int, String, String, String, String)140 %n/a114411
AudioBook(String, String, int, String, String, String)130 %n/a114411
toString()80 %n/a111111
getLanguage()30 %n/a111111
getCategory()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/AudioBook.java.html b/target/site/jacoco/musichub.business/AudioBook.java.html new file mode 100644 index 0000000..33a7924 --- /dev/null +++ b/target/site/jacoco/musichub.business/AudioBook.java.html @@ -0,0 +1,79 @@ +AudioBook.java

AudioBook.java

package musichub.business;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class AudioBook extends AudioElement {
+    private Language language;
+    private Category category;
+
+    public AudioBook(String title, String artist, int lengthInSeconds, String uid, String content, String language, String category) {
+        super(title, artist, lengthInSeconds, uid, content);
+        this.setLanguage(language);
+        this.setCategory(category);
+    }
+
+    public AudioBook(String title, String artist, int lengthInSeconds, String content, String language, String category) {
+        super(title, artist, lengthInSeconds, content);
+        this.setLanguage(language);
+        this.setCategory(category);
+    }
+
+    public AudioBook(Element xmlElement) {
+        super(xmlElement);
+        this.setLanguage(xmlElement.getElementsByTagName("language").item(0).getTextContent());
+        this.setCategory(xmlElement.getElementsByTagName("category").item(0).getTextContent());
+    }
+
+    public Language getLanguage() {
+        return this.language;
+    }
+
+    public void setLanguage(String language) {
+        switch (language.toLowerCase()) {
+            default -> this.language = Language.ENGLISH;
+            case "french" -> this.language = Language.FRENCH;
+            case "german" -> this.language = Language.GERMAN;
+            case "spanish" -> this.language = Language.SPANISH;
+            case "italian" -> this.language = Language.ITALIAN;
+        }
+    }
+
+    public Category getCategory() {
+        return this.category;
+    }
+
+    public void setCategory(String category) {
+        switch (category.toLowerCase()) {
+            default -> this.category = Category.YOUTH;
+            case "novel" -> this.category = Category.NOVEL;
+            case "theater" -> this.category = Category.THEATER;
+            case "documentary" -> this.category = Category.DOCUMENTARY;
+            case "speech" -> this.category = Category.SPEECH;
+        }
+    }
+
+
+    public String toString() {
+        return super.toString() + ", Language = " + getLanguage() + ", Category = " + getCategory() + "\n";
+    }
+
+
+    public void createXMLElement(Document document, Element parentElement) {
+        // audiobook element
+        Element audioBook = document.createElement("audiobook");
+
+        super.createXMLElement(document, audioBook);
+
+        Element languageElement = document.createElement("language");
+        languageElement.appendChild(document.createTextNode(language.getLanguage()));
+        audioBook.appendChild(languageElement);
+
+        Element categoryElement = document.createElement("category");
+        categoryElement.appendChild(document.createTextNode(category.getCategory()));
+        audioBook.appendChild(categoryElement);
+
+        parentElement.appendChild(audioBook);
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/AudioElement.html b/target/site/jacoco/musichub.business/AudioElement.html new file mode 100644 index 0000000..7a6e499 --- /dev/null +++ b/target/site/jacoco/musichub.business/AudioElement.html @@ -0,0 +1 @@ +AudioElement

AudioElement

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total266 of 2660 %11 of 110 %1616727299
createXMLElement(Document, Element)790 %n/a11161611
manageAudioElement()680 %70 %66242411
AudioElement(Element)630 %40 %33141411
AudioElement(String, String, int, String, String)190 %n/a117711
AudioElement(String, String, int, String)180 %n/a117711
toString()100 %n/a111111
getUUID()30 %n/a111111
getArtist()30 %n/a111111
getTitle()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/AudioElement.java.html b/target/site/jacoco/musichub.business/AudioElement.java.html new file mode 100644 index 0000000..4401836 --- /dev/null +++ b/target/site/jacoco/musichub.business/AudioElement.java.html @@ -0,0 +1,133 @@ +AudioElement.java

AudioElement.java

package musichub.business;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Scanner;
+import java.util.UUID;
+
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.UnsupportedAudioFileException;
+
+public abstract class AudioElement {
+    protected String title;
+    protected String artist;
+    protected int lengthInSeconds;
+    protected UUID uuid;
+    protected String content;
+
+    public AudioElement(String title, String artist, int lengthInSeconds, String id, String content) {
+        this.title = title;
+        this.artist = artist;
+        this.lengthInSeconds = lengthInSeconds;
+        this.uuid = UUID.fromString(id);
+        this.content = content;
+    }
+
+    public AudioElement(String title, String artist, int lengthInSeconds, String content) {
+        this.title = title;
+        this.artist = artist;
+        this.lengthInSeconds = lengthInSeconds;
+        this.content = content;
+        this.uuid = UUID.randomUUID();
+    }
+
+    public AudioElement(Element xmlElement) {
+        {
+            title = xmlElement.getElementsByTagName("title").item(0).getTextContent();
+            artist = xmlElement.getElementsByTagName("artist").item(0).getTextContent();
+            lengthInSeconds = Integer.parseInt(xmlElement.getElementsByTagName("length").item(0).getTextContent());
+            content = xmlElement.getElementsByTagName("content").item(0).getTextContent();
+            String uuid = null;
+            try {
+                uuid = xmlElement.getElementsByTagName("UUID").item(0).getTextContent();
+            } catch (Exception ex) {
+                System.out.println("Empty element UUID, will create a new one");
+            }
+            if ((uuid == null) || (uuid.isEmpty()))
+                this.uuid = UUID.randomUUID();
+            else this.uuid = UUID.fromString(uuid);
+        }
+    }
+
+    public UUID getUUID() {
+        return this.uuid;
+    }
+
+    public String getArtist() {
+        return this.artist;
+    }
+
+    public String getTitle() {
+        return this.title;
+    }
+
+    public String toString() {
+        return "Title = " + this.title + ", Artist = " + this.artist + ", Length = " + this.lengthInSeconds + ", Content = " + this.content;
+    }
+
+    public void createXMLElement(Document document, Element parentElement) {
+        Element nameElement = document.createElement("title");
+        nameElement.appendChild(document.createTextNode(title));
+        parentElement.appendChild(nameElement);
+
+        Element artistElement = document.createElement("artist");
+        artistElement.appendChild(document.createTextNode(artist));
+        parentElement.appendChild(artistElement);
+
+        Element lengthElement = document.createElement("length");
+        lengthElement.appendChild(document.createTextNode(Integer.valueOf(lengthInSeconds).toString()));
+        parentElement.appendChild(lengthElement);
+
+        Element UUIDElement = document.createElement("UUID");
+        UUIDElement.appendChild(document.createTextNode(uuid.toString()));
+        parentElement.appendChild(UUIDElement);
+
+        Element contentElement = document.createElement("content");
+        contentElement.appendChild(document.createTextNode(content));
+        parentElement.appendChild(contentElement);
+
+    }
+    
+    public void manageAudioElement() throws UnsupportedAudioFileException, IOException, LineUnavailableException {
+    	
+    	Scanner scanner = new Scanner(System.in); 
+    	
+    	File file = new File(this.content);
+    	AudioInputStream audioStream = AudioSystem.getAudioInputStream(file);
+    	Clip clip = AudioSystem.getClip();
+    	clip.open(audioStream);
+    	
+    	String action = "";
+    			
+    	while(!action.equals("Q")) {
+    		System.out.println("P = Play \b S = Stop \b R = Reset \b Q = Quit");
+    		System.out.println("Enter your choice");
+    		action = scanner.next();
+        	action = action.toUpperCase();
+        	
+        	switch(action) {
+        		case "S" : clip.stop();
+        		break;
+        		case "P" : clip.start();
+        		break;
+        		case "R" : clip.setMicrosecondPosition(0);
+        		break;
+        		case "Q" : clip.stop();
+        		break;
+        		default : System.out.println("try again");
+        	}
+        	System.out.println("You stoped the Audio element");
+    	}
+    	
+    	clip.close();
+    
+    }
+
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Category.html b/target/site/jacoco/musichub.business/Category.html new file mode 100644 index 0000000..d7e4df0 --- /dev/null +++ b/target/site/jacoco/musichub.business/Category.html @@ -0,0 +1 @@ +Category

Category

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total49 of 490 %0 of 0n/a336633
static {...}380 %n/a112211
Category(String, int, String)80 %n/a113311
getCategory()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Category.java.html b/target/site/jacoco/musichub.business/Category.java.html new file mode 100644 index 0000000..cdef51f --- /dev/null +++ b/target/site/jacoco/musichub.business/Category.java.html @@ -0,0 +1,15 @@ +Category.java

Category.java

package musichub.business;
+
+public enum Category {
+    YOUTH("youth"), NOVEL("novel"), THEATER("theater"), DOCUMENTARY("documentary"), SPEECH("speech");
+    private final String category;
+
+    Category(String category) {
+        this.category = category;
+    }
+
+    public String getCategory() {
+        return category;
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Genre.html b/target/site/jacoco/musichub.business/Genre.html new file mode 100644 index 0000000..88e0ecd --- /dev/null +++ b/target/site/jacoco/musichub.business/Genre.html @@ -0,0 +1 @@ +Genre

Genre

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total56 of 560 %0 of 0n/a336633
static {...}450 %n/a112211
Genre(String, int, String)80 %n/a113311
getGenre()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Genre.java.html b/target/site/jacoco/musichub.business/Genre.java.html new file mode 100644 index 0000000..021bb4b --- /dev/null +++ b/target/site/jacoco/musichub.business/Genre.java.html @@ -0,0 +1,15 @@ +Genre.java

Genre.java

package musichub.business;
+
+public enum Genre {
+    JAZZ("jazz"), CLASSIC("classic"), HIPHOP("hiphop"), ROCK("rock"), POP("pop"), RAP("rap");
+    private final String genre;
+
+    Genre(String genre) {
+        this.genre = genre;
+    }
+
+    public String getGenre() {
+        return genre;
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Language.html b/target/site/jacoco/musichub.business/Language.html new file mode 100644 index 0000000..604af85 --- /dev/null +++ b/target/site/jacoco/musichub.business/Language.html @@ -0,0 +1 @@ +Language

Language

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total49 of 490 %0 of 0n/a336633
static {...}380 %n/a112211
Language(String, int, String)80 %n/a113311
getLanguage()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Language.java.html b/target/site/jacoco/musichub.business/Language.java.html new file mode 100644 index 0000000..f974811 --- /dev/null +++ b/target/site/jacoco/musichub.business/Language.java.html @@ -0,0 +1,15 @@ +Language.java

Language.java

package musichub.business;
+
+public enum Language {
+    FRENCH("french"), ENGLISH("english"), ITALIAN("italian"), SPANISH("spanish"), GERMAN("german");
+    private final String language;
+
+    Language(String language) {
+        this.language = language;
+    }
+
+    public String getLanguage() {
+        return language;
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/MusicHub.html b/target/site/jacoco/musichub.business/MusicHub.html new file mode 100644 index 0000000..6bedc98 --- /dev/null +++ b/target/site/jacoco/musichub.business/MusicHub.html @@ -0,0 +1 @@ +MusicHub

MusicHub

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total803 of 8030 %114 of 1140 %79791951952222
addElementToAlbum(String, String)820 %120 %77202011
addElementToPlayList(String, String)820 %120 %77202011
getAlbumSongsSortedByGenre(String)790 %140 %88161611
getAlbumSongs(String)730 %140 %88151511
loadElements()640 %100 %66181811
getAudiobooksTitlesSortedByAuthor()530 %60 %449911
saveElements()470 %80 %55121211
loadAlbums()440 %80 %55111111
loadPlaylists()440 %80 %55111111
deletePlayList(String)400 %80 %55111111
saveAlbums()360 %40 %33101011
savePlayLists()360 %40 %33101011
getAlbumsTitlesSortedByDate()320 %20 %225511
MusicHub()290 %n/a119911
getAudioElement(List, String)190 %40 %335511
static {...}130 %n/a114411
addElement(AudioElement)60 %n/a112211
addAlbum(Album)60 %n/a112211
addPlaylist(PlayList)60 %n/a112211
albums()40 %n/a111111
playlists()40 %n/a111111
elements()40 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/MusicHub.java.html b/target/site/jacoco/musichub.business/MusicHub.java.html new file mode 100644 index 0000000..b9dfd09 --- /dev/null +++ b/target/site/jacoco/musichub.business/MusicHub.java.html @@ -0,0 +1,343 @@ +MusicHub.java

MusicHub.java

package musichub.business;
+
+import musichub.util.XMLHandler;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.IOException;
+import java.util.*;
+
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.UnsupportedAudioFileException;
+
+class SortByDate implements Comparator<Album> {
+    public int compare(Album a1, Album a2) {
+        return a1.getDate().compareTo(a2.getDate());
+    }
+}
+
+class SortByGenre implements Comparator<Song> {
+    public int compare(Song s1, Song s2) {
+        return s1.getGenre().compareTo(s2.getGenre());
+    }
+}
+
+class SortByAuthor implements Comparator<AudioElement> {
+    public int compare(AudioElement e1, AudioElement e2) {
+        return e1.getArtist().compareTo(e2.getArtist());
+    }
+}
+
+public class MusicHub {
+    public static final String DIR = System.getProperty("user.dir");
+    public static final String ALBUMS_FILE_PATH = DIR + "/files/albums.xml";
+    public static final String PLAYLISTS_FILE_PATH = DIR + "/files/playlists.xml";
+    public static final String ELEMENTS_FILE_PATH = DIR + "/files/elements.xml";
+    private final List<Album> albums;
+    private final List<PlayList> playlists;
+    private final List<AudioElement> elements;
+    private final XMLHandler xmlHandler = new XMLHandler();
+
+    public MusicHub() {
+        albums = new LinkedList<>();
+        playlists = new LinkedList<>();
+        elements = new LinkedList<>();
+        this.loadElements();
+        this.loadAlbums();
+        this.loadPlaylists();
+    }
+
+    public void addElement(AudioElement element) {
+        elements.add(element);
+    }
+
+    public void addAlbum(Album album) {
+        albums.add(album);
+    }
+
+    public void addPlaylist(PlayList playlist) {
+        playlists.add(playlist);
+    }
+
+    public void deletePlayList(String playListTitle) throws NoPlayListFoundException {
+
+        PlayList thePlayList = null;
+        boolean result = false;
+        for (PlayList pl : playlists) {
+            if (pl.getTitle().equalsIgnoreCase(playListTitle)) {
+                thePlayList = pl;
+                break;
+            }
+        }
+
+        if (thePlayList != null)
+            result = playlists.remove(thePlayList);
+        if (!result) throw new NoPlayListFoundException("Playlist " + playListTitle + " not found!");
+    }
+
+    public Iterator<Album> albums() {
+        return albums.listIterator();
+    }
+
+    public Iterator<PlayList> playlists() {
+        return playlists.listIterator();
+    }
+
+    public Iterator<AudioElement> elements() {
+        return elements.listIterator();
+    }
+
+    public String getAlbumsTitlesSortedByDate() {
+        StringBuilder titleList = new StringBuilder();
+        albums.sort(new SortByDate());
+        for (Album al : albums)
+            titleList.append(al.getTitle()).append("\n");
+        return titleList.toString();
+    }
+
+    public String getAudiobooksTitlesSortedByAuthor() {
+        StringBuilder titleList = new StringBuilder();
+        List<AudioElement> audioBookList = new ArrayList<>();
+        for (AudioElement ae : elements)
+            if (ae instanceof AudioBook)
+                audioBookList.add(ae);
+        audioBookList.sort(new SortByAuthor());
+        for (AudioElement ab : audioBookList)
+            titleList.append(ab.getArtist()).append("\n");
+        return titleList.toString();
+    }
+
+    public List<AudioElement> getAlbumSongs(String albumTitle) throws NoAlbumFoundException {
+        Album theAlbum = null;
+        ArrayList<AudioElement> songsInAlbum = new ArrayList<>();
+        for (Album al : albums) {
+            if (al.getTitle().equalsIgnoreCase(albumTitle)) {
+                theAlbum = al;
+                break;
+            }
+        }
+        if (theAlbum == null) throw new NoAlbumFoundException("No album with this title in the MusicHub!");
+
+        List<UUID> songIDs = theAlbum.getSongs();
+        for (UUID id : songIDs)
+            for (AudioElement el : elements) {
+                if (el instanceof Song) {
+                    if (el.getUUID().equals(id)) songsInAlbum.add(el);
+                }
+            }
+        return songsInAlbum;
+
+    }
+
+    public List<Song> getAlbumSongsSortedByGenre(String albumTitle) throws NoAlbumFoundException {
+        Album theAlbum = null;
+        ArrayList<Song> songsInAlbum = new ArrayList<>();
+        for (Album al : albums) {
+            if (al.getTitle().equalsIgnoreCase(albumTitle)) {
+                theAlbum = al;
+                break;
+            }
+        }
+        if (theAlbum == null) throw new NoAlbumFoundException("No album with this title in the MusicHub!");
+
+        List<UUID> songIDs = theAlbum.getSongs();
+        for (UUID id : songIDs)
+            for (AudioElement el : elements) {
+                if (el instanceof Song) {
+                    if (el.getUUID().equals(id)) songsInAlbum.add((Song) el);
+                }
+            }
+        songsInAlbum.sort(new SortByGenre());
+        return songsInAlbum;
+
+    }
+
+    public void addElementToAlbum(String elementTitle, String albumTitle) throws NoAlbumFoundException, NoElementFoundException {
+        Album theAlbum = null;
+        int i;
+        boolean found = false;
+        for (i = 0; i < albums.size(); i++) {
+            if (albums.get(i).getTitle().equalsIgnoreCase(albumTitle)) {
+                theAlbum = albums.get(i);
+                found = true;
+                break;
+            }
+        }
+
+        if (found) {
+            AudioElement theElement = null;
+            for (AudioElement ae : elements) {
+                if (ae.getTitle().equalsIgnoreCase(elementTitle)) {
+                    theElement = ae;
+                    break;
+                }
+            }
+            if (theElement != null) {
+                theAlbum.addSong(theElement.getUUID());
+                //replace the album in the list
+                albums.set(i, theAlbum);
+            } else throw new NoElementFoundException("Element " + elementTitle + " not found!");
+        } else throw new NoAlbumFoundException("Album " + albumTitle + " not found!");
+
+    }
+
+    public void addElementToPlayList(String elementTitle, String playListTitle) throws NoPlayListFoundException, NoElementFoundException {
+        PlayList thePlaylist = null;
+        int i;
+        boolean found = false;
+
+        for (i = 0; i < playlists.size(); i++) {
+            if (playlists.get(i).getTitle().equalsIgnoreCase(playListTitle)) {
+                thePlaylist = playlists.get(i);
+                found = true;
+                break;
+            }
+        }
+
+        if (found) {
+            AudioElement theElement = null;
+            for (AudioElement ae : elements) {
+                if (ae.getTitle().equalsIgnoreCase(elementTitle)) {
+                    theElement = ae;
+                    break;
+                }
+            }
+            if (theElement != null) {
+                thePlaylist.addElement(theElement.getUUID());
+                //replace the album in the list
+                playlists.set(i, thePlaylist);
+            } else throw new NoElementFoundException("Element " + elementTitle + " not found!");
+
+        } else throw new NoPlayListFoundException("Playlist " + playListTitle + " not found!");
+
+    }
+
+    private void loadAlbums() {
+        NodeList albumNodes = xmlHandler.parseXMLFile(ALBUMS_FILE_PATH);
+        if (albumNodes == null) return;
+
+        for (int i = 0; i < albumNodes.getLength(); i++) {
+            if (albumNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
+                Element albumElement = (Element) albumNodes.item(i);
+                if (albumElement.getNodeName().equals("album")) {
+                    try {
+                        this.addAlbum(new Album(albumElement));
+                    } catch (Exception ex) {
+                        System.out.println("Something is wrong with the XML album element");
+                    }
+                }
+            }
+        }
+    }
+
+    private void loadPlaylists() {
+        NodeList playlistNodes = xmlHandler.parseXMLFile(PLAYLISTS_FILE_PATH);
+        if (playlistNodes == null) return;
+
+        for (int i = 0; i < playlistNodes.getLength(); i++) {
+            if (playlistNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
+                Element playlistElement = (Element) playlistNodes.item(i);
+                if (playlistElement.getNodeName().equals("playlist")) {
+                    try {
+                        this.addPlaylist(new PlayList(playlistElement));
+                    } catch (Exception ex) {
+                        System.out.println("Something is wrong with the XML playlist element");
+                    }
+                }
+            }
+        }
+    }
+
+    private void loadElements() {
+        NodeList audioelementsNodes = xmlHandler.parseXMLFile(ELEMENTS_FILE_PATH);
+        if (audioelementsNodes == null) return;
+
+        for (int i = 0; i < audioelementsNodes.getLength(); i++) {
+            if (audioelementsNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
+                Element audioElement = (Element) audioelementsNodes.item(i);
+                if (audioElement.getNodeName().equals("song")) {
+                    try {
+                        AudioElement newSong = new Song(audioElement);
+                        this.addElement(newSong);
+                    } catch (Exception ex) {
+                        System.out.println("Something is wrong with the XML song element");
+                    }
+                }
+                if (audioElement.getNodeName().equals("audiobook")) {
+                    try {
+                        AudioElement newAudioBook = new AudioBook(audioElement);
+                        this.addElement(newAudioBook);
+                    } catch (Exception ex) {
+                        System.out.println("Something is wrong with the XML audiobook element");
+                    }
+                }
+            }
+        }
+    }
+
+
+    public void saveAlbums() {
+        Document document = xmlHandler.createXMLDocument();
+        if (document == null) return;
+
+        // root element
+        Element root = document.createElement("albums");
+        document.appendChild(root);
+
+        //save all albums
+        for (Iterator<Album> albumsIter = this.albums(); albumsIter.hasNext(); ) {
+            Album currentAlbum = albumsIter.next();
+            currentAlbum.createXMLElement(document, root);
+        }
+        xmlHandler.createXMLFile(document, ALBUMS_FILE_PATH);
+    }
+
+    public void savePlayLists() {
+        Document document = xmlHandler.createXMLDocument();
+        if (document == null) return;
+
+        // root element
+        Element root = document.createElement("playlists");
+        document.appendChild(root);
+
+        //save all playlists
+        for (Iterator<PlayList> playlistsIter = this.playlists(); playlistsIter.hasNext(); ) {
+            PlayList currentPlayList = playlistsIter.next();
+            currentPlayList.createXMLElement(document, root);
+        }
+        xmlHandler.createXMLFile(document, PLAYLISTS_FILE_PATH);
+    }
+
+    public void saveElements() {
+        Document document = xmlHandler.createXMLDocument();
+        if (document == null) return;
+
+        // root element
+        Element root = document.createElement("elements");
+        document.appendChild(root);
+
+        //save all AudioElements
+        for (AudioElement currentElement : elements) {
+
+            if (currentElement instanceof Song) {
+                currentElement.createXMLElement(document, root);
+            }
+            if (currentElement instanceof AudioBook) {
+                currentElement.createXMLElement(document, root);
+            }
+        }
+        xmlHandler.createXMLFile(document, ELEMENTS_FILE_PATH);
+    }
+    
+    public void getAudioElement(List<AudioElement> audios, String elementTitle) throws NoAlbumFoundException, UnsupportedAudioFileException, IOException, LineUnavailableException {
+        for (AudioElement el : audios) {
+            if (el.getTitle().equalsIgnoreCase(elementTitle)) {
+                el.manageAudioElement();
+            }
+        }
+
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/NoAlbumFoundException.html b/target/site/jacoco/musichub.business/NoAlbumFoundException.html new file mode 100644 index 0000000..51bf5be --- /dev/null +++ b/target/site/jacoco/musichub.business/NoAlbumFoundException.html @@ -0,0 +1 @@ +NoAlbumFoundException

NoAlbumFoundException

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total4 of 40 %0 of 0n/a112211
NoAlbumFoundException(String)40 %n/a112211
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/NoAlbumFoundException.java.html b/target/site/jacoco/musichub.business/NoAlbumFoundException.java.html new file mode 100644 index 0000000..d78347b --- /dev/null +++ b/target/site/jacoco/musichub.business/NoAlbumFoundException.java.html @@ -0,0 +1,9 @@ +NoAlbumFoundException.java

NoAlbumFoundException.java

package musichub.business;
+
+public class NoAlbumFoundException extends Exception {
+
+    public NoAlbumFoundException(String msg) {
+        super(msg);
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/NoElementFoundException.html b/target/site/jacoco/musichub.business/NoElementFoundException.html new file mode 100644 index 0000000..01fecbd --- /dev/null +++ b/target/site/jacoco/musichub.business/NoElementFoundException.html @@ -0,0 +1 @@ +NoElementFoundException

NoElementFoundException

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total4 of 40 %0 of 0n/a112211
NoElementFoundException(String)40 %n/a112211
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/NoElementFoundException.java.html b/target/site/jacoco/musichub.business/NoElementFoundException.java.html new file mode 100644 index 0000000..4d5f6bb --- /dev/null +++ b/target/site/jacoco/musichub.business/NoElementFoundException.java.html @@ -0,0 +1,9 @@ +NoElementFoundException.java

NoElementFoundException.java

package musichub.business;
+
+public class NoElementFoundException extends Exception {
+
+    public NoElementFoundException(String msg) {
+        super(msg);
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/NoPlayListFoundException.html b/target/site/jacoco/musichub.business/NoPlayListFoundException.html new file mode 100644 index 0000000..d1803ad --- /dev/null +++ b/target/site/jacoco/musichub.business/NoPlayListFoundException.html @@ -0,0 +1 @@ +NoPlayListFoundException

NoPlayListFoundException

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total4 of 40 %0 of 0n/a112211
NoPlayListFoundException(String)40 %n/a112211
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/NoPlayListFoundException.java.html b/target/site/jacoco/musichub.business/NoPlayListFoundException.java.html new file mode 100644 index 0000000..f93e9a4 --- /dev/null +++ b/target/site/jacoco/musichub.business/NoPlayListFoundException.java.html @@ -0,0 +1,9 @@ +NoPlayListFoundException.java

NoPlayListFoundException.java

package musichub.business;
+
+public class NoPlayListFoundException extends Exception {
+
+    public NoPlayListFoundException(String msg) {
+        super(msg);
+    }
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/PathValidation.html b/target/site/jacoco/musichub.business/PathValidation.html new file mode 100644 index 0000000..3b58bb2 --- /dev/null +++ b/target/site/jacoco/musichub.business/PathValidation.html @@ -0,0 +1 @@ +PathValidation

PathValidation

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total0 of 17100 %0 of 0n/a020402
isPathValid(String)10100 %n/a010201
PathValidation()7100 %n/a010201
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/PathValidation.java.html b/target/site/jacoco/musichub.business/PathValidation.java.html new file mode 100644 index 0000000..4d22953 --- /dev/null +++ b/target/site/jacoco/musichub.business/PathValidation.java.html @@ -0,0 +1,39 @@ +PathValidation.java

PathValidation.java

package musichub.business;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Class offering a path validation method.
+ *
+ * @author Aimeric ADJUTOR
+ * @version 1.0
+ */
+
+public final class PathValidation {
+
+    /**
+     * Method that just throws an AssertionError if the class is called
+     * @author Aimeric ADJUTOR
+     * @throws AssertionError you can't instantiate this class
+     */
+
+    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
+     */
+
+    public static boolean isPathValid(String inputPath) {
+        Path path = Paths.get(inputPath);
+        return Files.exists(path);
+    }
+
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/PlayList.html b/target/site/jacoco/musichub.business/PlayList.html new file mode 100644 index 0000000..ae17a14 --- /dev/null +++ b/target/site/jacoco/musichub.business/PlayList.html @@ -0,0 +1 @@ +PlayList

PlayList

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total202 of 2020 %14 of 140 %1414535377
PlayList(Element)880 %120 %77232311
createXMLElement(Document, Element)750 %20 %22161611
PlayList(String)140 %n/a115511
PlayList(String, String, ArrayList)130 %n/a115511
addElement(UUID)60 %n/a112211
getElements()30 %n/a111111
getTitle()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/PlayList.java.html b/target/site/jacoco/musichub.business/PlayList.java.html new file mode 100644 index 0000000..6a45004 --- /dev/null +++ b/target/site/jacoco/musichub.business/PlayList.java.html @@ -0,0 +1,101 @@ +PlayList.java

PlayList.java

package musichub.business;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+import java.util.UUID;
+
+public class PlayList {
+    private final String title;
+    private final UUID uuid;
+    private ArrayList<UUID> elementUUIDs;
+
+    public PlayList(String title, String id, ArrayList<UUID> elementUUIDs) {
+        this.title = title;
+        this.uuid = UUID.fromString(id);
+        this.elementUUIDs = elementUUIDs;
+    }
+
+    public PlayList(String title) {
+        this.title = title;
+        this.uuid = UUID.randomUUID();
+        this.elementUUIDs = new ArrayList<>();
+    }
+
+    public PlayList(Element xmlElement) {
+        {
+            this.title = xmlElement.getElementsByTagName("title").item(0).getTextContent();
+
+            String uuid = null;
+            try {
+                uuid = xmlElement.getElementsByTagName("UUID").item(0).getTextContent();
+            } catch (Exception ex) {
+                System.out.println("Empty playlist UUID, will create a new one");
+            }
+            if ((uuid == null) || (uuid.isEmpty()))
+                this.uuid = UUID.randomUUID();
+            else this.uuid = UUID.fromString(uuid);
+
+            //parse list of elements:
+            Node elementsElement = xmlElement.getElementsByTagName("elements").item(0);
+            NodeList elementUUIDNodes = elementsElement.getChildNodes();
+            if (elementUUIDNodes == null) return;
+
+            this.elementUUIDs = new ArrayList<>();
+
+
+            for (int i = 0; i < elementUUIDNodes.getLength(); i++) {
+                if (elementUUIDNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
+                    Element elementElement = (Element) elementUUIDNodes.item(i);
+                    if (elementElement.getNodeName().equals("UUID")) {
+                        try {
+                            this.addElement(UUID.fromString(elementElement.getTextContent()));
+                        } catch (Exception ex) {
+                            ex.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void addElement(UUID element) {
+        elementUUIDs.add(element);
+    }
+
+    public ArrayList<UUID> getElements() {
+        return elementUUIDs;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void createXMLElement(Document document, Element parentElement) {
+        Element playlistElement = document.createElement("playlist");
+        parentElement.appendChild(playlistElement);
+
+        Element nameElement = document.createElement("title");
+        nameElement.appendChild(document.createTextNode(title));
+        playlistElement.appendChild(nameElement);
+
+        Element UUIDElement = document.createElement("UUID");
+        UUIDElement.appendChild(document.createTextNode(uuid.toString()));
+        playlistElement.appendChild(UUIDElement);
+
+
+        Element elementsElement = document.createElement("elements");
+        for (UUID currentUUID : this.elementUUIDs) {
+
+            Element elementUUIDElement = document.createElement("UUID");
+            elementUUIDElement.appendChild(document.createTextNode(currentUUID.toString()));
+            elementsElement.appendChild(elementUUIDElement);
+        }
+        playlistElement.appendChild(elementsElement);
+    }
+
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Song.html b/target/site/jacoco/musichub.business/Song.html new file mode 100644 index 0000000..4af18c3 --- /dev/null +++ b/target/site/jacoco/musichub.business/Song.html @@ -0,0 +1 @@ +Song

Song

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total105 of 1050 %6 of 60 %1212262677
setGenre(String)330 %60 %668811
createXMLElement(Document, Element)290 %n/a117711
Song(Element)120 %n/a113311
Song(String, String, int, String, String, String)110 %n/a113311
Song(String, String, int, String, String)100 %n/a113311
toString()60 %n/a111111
getGenre()40 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/Song.java.html b/target/site/jacoco/musichub.business/Song.java.html new file mode 100644 index 0000000..4f7f01d --- /dev/null +++ b/target/site/jacoco/musichub.business/Song.java.html @@ -0,0 +1,59 @@ +Song.java

Song.java

package musichub.business;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+
+public class Song extends AudioElement {
+    private Genre genre;
+
+    public Song(String title, String artist, int length, String uid, String content, String genre) {
+        super(title, artist, length, uid, content);
+        this.setGenre(genre);
+    }
+
+    public Song(String title, String artist, int length, String content, String genre) {
+        super(title, artist, length, content);
+        this.setGenre(genre);
+    }
+
+    public Song(Element xmlElement) {
+        super(xmlElement);
+        this.setGenre(xmlElement.getElementsByTagName("genre").item(0).getTextContent());
+    }
+
+    public String getGenre() {
+        return genre.getGenre();
+    }
+
+    public void setGenre(String genre) {
+        switch (genre.toLowerCase()) {
+            default -> this.genre = Genre.JAZZ;
+            case "classic" -> this.genre = Genre.CLASSIC;
+            case "hiphop" -> this.genre = Genre.HIPHOP;
+            case "rock" -> this.genre = Genre.ROCK;
+            case "pop" -> this.genre = Genre.POP;
+            case "rap" -> this.genre = Genre.RAP;
+        }
+    }
+
+    public String toString() {
+        return super.toString() + ", Genre = " + getGenre() + "\n";
+    }
+
+    public void createXMLElement(Document document, Element parentElement) {
+        // song element
+        Element song = document.createElement("song");
+
+        super.createXMLElement(document, song);
+
+        Element genreElement = document.createElement("genre");
+        genreElement.appendChild(document.createTextNode(genre.getGenre()));
+        song.appendChild(genreElement);
+
+        parentElement.appendChild(song);
+    }
+    
+
+}
+
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/SortByAuthor.html b/target/site/jacoco/musichub.business/SortByAuthor.html new file mode 100644 index 0000000..851cdce --- /dev/null +++ b/target/site/jacoco/musichub.business/SortByAuthor.html @@ -0,0 +1 @@ +SortByAuthor

SortByAuthor

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total9 of 90 %0 of 0n/a222222
compare(AudioElement, AudioElement)60 %n/a111111
SortByAuthor()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/SortByDate.html b/target/site/jacoco/musichub.business/SortByDate.html new file mode 100644 index 0000000..8f4b2f7 --- /dev/null +++ b/target/site/jacoco/musichub.business/SortByDate.html @@ -0,0 +1 @@ +SortByDate

SortByDate

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total9 of 90 %0 of 0n/a222222
compare(Album, Album)60 %n/a111111
SortByDate()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/SortByGenre.html b/target/site/jacoco/musichub.business/SortByGenre.html new file mode 100644 index 0000000..6dd6e7d --- /dev/null +++ b/target/site/jacoco/musichub.business/SortByGenre.html @@ -0,0 +1 @@ +SortByGenre

SortByGenre

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total9 of 90 %0 of 0n/a222222
compare(Song, Song)60 %n/a111111
SortByGenre()30 %n/a111111
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/index.html b/target/site/jacoco/musichub.business/index.html new file mode 100644 index 0000000..178e60b --- /dev/null +++ b/target/site/jacoco/musichub.business/index.html @@ -0,0 +1 @@ +musichub.business

musichub.business

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total2 063 of 2 0800 %169 of 1690 %17217449950381831516
MusicHub8030 %1140 %7979195195222211
Album3300 %140 %161684849911
AudioElement2660 %110 %161672729911
PlayList2020 %140 %141453537711
AudioBook1640 %100 %171739399911
Song1050 %60 %121226267711
Genre560 %n/a33663311
Language490 %n/a33663311
Category490 %n/a33663311
SortByAuthor90 %n/a22222211
SortByDate90 %n/a22222211
SortByGenre90 %n/a22222211
NoAlbumFoundException0 %n/a11221111
NoPlayListFoundException0 %n/a11221111
NoElementFoundException0 %n/a11221111
PathValidation17100 %n/a02040201
\ No newline at end of file diff --git a/target/site/jacoco/musichub.business/index.source.html b/target/site/jacoco/musichub.business/index.source.html new file mode 100644 index 0000000..45a5b59 --- /dev/null +++ b/target/site/jacoco/musichub.business/index.source.html @@ -0,0 +1 @@ +musichub.business

musichub.business

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total2 063 of 2 0800 %169 of 1690 %17217449950381831516
MusicHub.java8300 %1140 %8585201201282844
Album.java3300 %140 %161684849911
AudioElement.java2660 %110 %161672729911
PlayList.java2020 %140 %141453537711
AudioBook.java1640 %100 %171739399911
Song.java1050 %60 %121226267711
Genre.java560 %n/a33663311
Language.java490 %n/a33663311
Category.java490 %n/a33663311
NoAlbumFoundException.java0 %n/a11221111
NoPlayListFoundException.java0 %n/a11221111
NoElementFoundException.java0 %n/a11221111
PathValidation.java17100 %n/a02040201
\ No newline at end of file -- cgit v1.2.3