Browse Source

added fourth test case for getInfoText() & and added productive code for RadioPlayer

feature-pr-RadioPlayer-getInfoText
Jan Ortner 3 years ago
parent
commit
f754c0a5ce
  1. 2
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 5
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -151,7 +151,7 @@ public class RadioPlayer implements Device {
public String getInfoText() { public String getInfoText() {
String infoText = playedStation; String infoText = playedStation;
if(regionPlaylist.contains(playedStation)) return ("Regional playlist " + infoText); if(regionPlaylist.contains(playedStation)) return ("Regional playlist " + infoText);
else return infoText;
else return ("Saved playlist " + infoText);
} }
@Override @Override

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

@ -382,6 +382,7 @@ class RadioPlayerTest {
if(testTyp.equals("null")) bool = Strings.isNullOrEmpty(testRp.getInfoText()); if(testTyp.equals("null")) bool = Strings.isNullOrEmpty(testRp.getInfoText());
else if(testTyp.contains("station")) bool = testRp.getInfoText().contains(testRp.playedStation); else if(testTyp.contains("station")) bool = testRp.getInfoText().contains(testRp.playedStation);
else if(testTyp.contains("region")) bool = testRp.getInfoText().contains("Regional playlist"); else if(testTyp.contains("region")) bool = testRp.getInfoText().contains("Regional playlist");
else if(testTyp.contains("saved")) bool = testRp.getInfoText().contains("Saved playlist");
assertThat(bool).describedAs(testName).isEqualTo(expectedResult); assertThat(bool).describedAs(testName).isEqualTo(expectedResult);
} }
@ -391,11 +392,13 @@ class RadioPlayerTest {
RadioPlayer rp1 = new RadioPlayer(); RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer(); RadioPlayer rp2 = new RadioPlayer();
rp2.changeRegion("BY"); rp2.changeRegion("BY");
RadioPlayer rp3 = new RadioPlayer();
return Stream.of( return Stream.of(
Arguments.of("Test for getInfoText is not empty or null", "null", rp, false), Arguments.of("Test for getInfoText is not empty or null", "null", rp, false),
Arguments.of("Test for getInfoText contains played station", "station", rp1, true), Arguments.of("Test for getInfoText contains played station", "station", rp1, true),
Arguments.of("Test for getInfoText contains regional playlist if played station is in it", "region", rp2, true)
Arguments.of("Test for getInfoText contains regional playlist if played station is in it", "region", rp2, true),
Arguments.of("Test for getInfoText contains saved playlist if played station is in it", "saved", rp3, true)
); );
} }
} }
Loading…
Cancel
Save