Browse Source

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

feature-pr-RadioPlayer-getInfoText
Jan Ortner 2 years ago
parent
commit
9d20decf08
  1. 4
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 10
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

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

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

@ -378,9 +378,10 @@ class RadioPlayerTest {
@ParameterizedTest
@MethodSource("getInfoTextOptions")
void testGetInfoText(String testName, String testTyp, RadioPlayer testRp, boolean expectedResult) {
Boolean bool;
Boolean bool = null;
if(testTyp.equals("null")) bool = Strings.isNullOrEmpty(testRp.getInfoText());
else 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");
assertThat(bool).describedAs(testName).isEqualTo(expectedResult);
}
@ -388,10 +389,13 @@ class RadioPlayerTest {
static Stream<Arguments> getInfoTextOptions() {
RadioPlayer rp = new RadioPlayer();
RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer();
rp2.changeRegion("BY");
return Stream.of(
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)
);
}
}
Loading…
Cancel
Save