From 0a02c7b9cdea159b75a781abdac4db4ab846240b Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Tue, 15 Feb 2022 16:56:33 +0100 Subject: [PATCH] added second test case for changeToSavedPlaylist() & and added productive code --- src/main/java/device/radioPlayer/RadioPlayer.java | 5 +++++ src/test/java/device/radioPlayer/RadioPlayerTest.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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") ); }