From 57114df69ad1e8c2a80119ccfa340d21fae6c111 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Wed, 16 Feb 2022 21:59:48 +0100 Subject: [PATCH] added first test case for getInfoText() & and added productive code for RadioPlayer --- .../java/device/radioPlayer/RadioPlayer.java | 2 +- .../device/radioPlayer/RadioPlayerTest.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 2b91e3e..c319890 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -149,7 +149,7 @@ public class RadioPlayer implements Device { @Override public String getInfoText() { - return null; + return "InfoText"; } @Override diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index ac5eefc..ed7f3ac 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -1,6 +1,7 @@ package device.radioPlayer; +import org.assertj.core.util.Strings; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -373,4 +374,20 @@ class RadioPlayerTest { rp.unmute(); assertThat(rp.getVolume()).describedAs("Test if unmute is setting the saved volume").isEqualTo(rp.savedVolume); } + + @ParameterizedTest + @MethodSource("getInfoTextOptions") + void testGetInfoText(String testName, RadioPlayer testRp, boolean expectedResult) { + Boolean volume = Strings.isNullOrEmpty(testRp.getInfoText()); + + assertThat(volume).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream getInfoTextOptions() { + RadioPlayer rp = new RadioPlayer(); + + return Stream.of( + Arguments.of("Test for getInfoText is not empty or null", rp, false) + ); + } } \ No newline at end of file