Browse Source

Merge commit '54ac5f48b32f398f1329ebd22b94b9fa36fe9e37' into HEAD

feature-pr-deleteStation
Jenkins 3 years ago
parent
commit
5d0e3168a2
  1. 5
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 7
      src/test/java/device/radioPlayer/RadioPlayerTest.java

5
src/main/java/device/radioPlayer/RadioPlayer.java

@ -164,7 +164,10 @@ public class RadioPlayer implements Device {
@Override
public String play() {
return ("Radio is playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation);
if (regionPlaylist.contains(playedStation))
return ("Radio is playing station: 0" + (regionPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from regional playlist");
else
return ("Radio is playing station: 0" + (savedPlaylist.indexOf(playedStation) + 1) + " " + this.playedStation + " from saved playlist");
}
public String showStationInfo() {

7
src/test/java/device/radioPlayer/RadioPlayerTest.java

@ -185,9 +185,12 @@ class RadioPlayerTest {
static Stream<Arguments> testPlayOptions() {
RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer();
rp2.changeRegion("BY");
return Stream.of(
Arguments.of("Test for playing first station on saved playlist", rp1, "Radio is playing station: 01 YouFM")
Arguments.of("Test for playing first station on saved playlist", rp1, "Radio is playing station: 01 YouFM from saved playlist"),
Arguments.of("Test for playing first station on regional playlist", rp2, "Radio is playing station: 01 Antenne Bayern from regional playlist")
);
}
@ -195,7 +198,7 @@ class RadioPlayerTest {
@MethodSource("saveStationOptions")
void testSaveStation(String testName, RadioPlayer testRp,String testTyp, String expectedResult) {
String savedStation;
if (testTyp == "normal") {
if (testTyp.equals("normal")) {
savedStation = testRp.savedPlaylist.get(testRp.savedPlaylist.size() - 1);}
else savedStation = Boolean.toString(testRp.regionPlaylist.isEmpty());
assertThat(savedStation).describedAs(testName).isEqualTo(expectedResult);

Loading…
Cancel
Save