diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 6f68676..f0ae7a3 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -114,7 +114,7 @@ public class RadioPlayer implements Device { @Override public void next() { - if (regionPlaylist.contains(playedStation)){ + if (regionPlaylist.contains(playedStation)) { int currentIndex = regionPlaylist.indexOf(playedStation); int nextIndex = (currentIndex + 1) % regionPlaylist.size(); playedStation = regionPlaylist.get(nextIndex); @@ -183,7 +183,9 @@ public class RadioPlayer implements Device { } public String saveStation() { - savedPlaylist.add(playedStation); - return ""; + if (savedPlaylist.contains(playedStation)) return "Station " + playedStation + " is already saved"; + else + savedPlaylist.add(playedStation); + return "Station " + playedStation + " is saved in your Station list"; } } diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index fcf7b3a..ce7114e 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -194,11 +194,14 @@ class RadioPlayerTest { static Stream saveStationOptions() { RadioPlayer rp1 = new RadioPlayer(); + RadioPlayer rp2 = new RadioPlayer(); rp1.changeRegion("BY"); rp1.saveStation(); + rp2.saveStation(); return Stream.of( - Arguments.of("Test for saving station in saved playlist", rp1, "Antenne Bayern") + Arguments.of("Test for saving station in saved playlist", rp1, "Antenne Bayern"), + Arguments.of("Test for not saving station which is already in saved playlist", rp2, "MegaHits") ); }