diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 849784d..075cd4a 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -203,6 +203,11 @@ public class RadioPlayer implements Device { } public String changeToSavedPlaylist() { + if(regionPlaylist.contains(playedStation)) { + playedStation = savedPlaylist.get(0); + regionPlaylist.clear(); + return "Playlist switched now playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from saved playlist"; + } return "You are already in saved Playlist!"; } } diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 7ab13b0..a92b654 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -255,9 +255,13 @@ class RadioPlayerTest { static Stream changeToSavedPlaylistOptions() { RadioPlayer rp = new RadioPlayer(); rp.changeToSavedPlaylist(); + RadioPlayer rp1 = new RadioPlayer(); + rp1.changeRegion("BY"); + rp1.changeToSavedPlaylist(); return Stream.of( - Arguments.of("Test for change to saved playlist when you already in saved playlist", rp, "YouFM") + Arguments.of("Test for change to saved playlist when you already in saved playlist", rp, "YouFM"), + Arguments.of("Test for change to saved playlist when in regional playlist", rp1, "YouFM") ); }