From d61ea260075e780a3eae25879f4a44ad28ef00c3 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Wed, 16 Feb 2022 19:54:41 +0100 Subject: [PATCH] added first test case for getItemList() & and added productive code for RadioPlayer --- src/main/java/device/radioPlayer/RadioPlayer.java | 2 +- .../java/device/radioPlayer/RadioPlayerTest.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index d7f35f1..1741dc6 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -185,7 +185,7 @@ public class RadioPlayer implements Device { @Override public String[] getItemList() { - return null; + return savedPlaylist.toArray(new String[0]); } @Override diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 0e8f008..b991a7f 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -320,4 +320,18 @@ class RadioPlayerTest { Arguments.of("Test for change order in saved playlist with nr is than smaller than 0 at front of playlist", rp2, 0, "Teddy") ); } + @ParameterizedTest + @MethodSource("getItemListOptions") + void testGetItemList(String testName, RadioPlayer testRp, String[] expectedResult) { + String[] playList = testRp.getItemList(); + assertThat(playList).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream getItemListOptions() { + RadioPlayer rp = new RadioPlayer(); + + return Stream.of( + Arguments.of("Test for return saved playlist", rp, rp.savedPlaylist.toArray(new String[0])) + ); + } } \ No newline at end of file