From aa3c6ef4d45af4925cd2af63875b8220441601d1 Mon Sep 17 00:00:00 2001 From: JPANZO Date: Tue, 15 Feb 2022 20:43:33 +0100 Subject: [PATCH] getOptions from CDPlayer tested on Returning Null. changes in the Interface 0.3. --- src/main/java/device/Device.java | 2 +- src/main/java/device/cdPlayer/CDPlayer.java | 6 +++--- .../java/device/radioPlayer/RadioPlayer.java | 2 +- src/main/java/device/usbPlayer/UsbPlayer.java | 2 +- src/test/java/device/cdPlayer/CDPlayerTest.java | 17 ++++++++++++++++- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/device/Device.java b/src/main/java/device/Device.java index 66a376d..a2a8c3f 100644 --- a/src/main/java/device/Device.java +++ b/src/main/java/device/Device.java @@ -14,7 +14,7 @@ public interface Device { //get an Item of the Album String chooseItem(int itemNr); // get the actual album - String getItemList(); + String[] getItemList(); String play(); } diff --git a/src/main/java/device/cdPlayer/CDPlayer.java b/src/main/java/device/cdPlayer/CDPlayer.java index e7c0ec5..66d8bfb 100644 --- a/src/main/java/device/cdPlayer/CDPlayer.java +++ b/src/main/java/device/cdPlayer/CDPlayer.java @@ -69,7 +69,7 @@ public class CDPlayer implements Device { @Override public String[] getOptions() { - return loadedCD.getPlayList(); + return new String[]{}; } @Override @@ -78,8 +78,8 @@ public class CDPlayer implements Device { } @Override - public String getItemList() { - return null; + public String[] getItemList() { + return loadedCD.getPlayList(); } @Override diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index f491dbc..858cf13 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -162,7 +162,7 @@ public class RadioPlayer implements Device { } @Override - public String getItemList() { + public String[] getItemList() { return null; } diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index da599bc..bf403d6 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -156,7 +156,7 @@ public class UsbPlayer implements Device { } @Override - public String getItemList() { + public String[] getItemList() { return null; } diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index 37cb277..171dda9 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -193,7 +193,7 @@ class CDPlayerTest { return Stream.of( Arguments.of("[getActualPlayTrack() after 1x next() starting by firstSong] => SecondSongSelected","SecondSongSelected", cdPlayer1, 1, cdPlayer1.getSongByNumber(1)), Arguments.of("[getActualPlayTrack() after 2x next() starting by firstSong] => ThirdSongSelected","ThirdSongSelected" ,cdPlayer2,2,cdPlayer2.getSongByNumber(2)), - Arguments.of("[getActualPlayTrack() after 1x next() starting by lastSong] => FirstSongSelected","FirstSongSelected", cdPlayer3,cdPlayer3.getOptions().length,cdPlayer3.getSongByNumber(0)) + Arguments.of("[getActualPlayTrack() after 1x next() starting by lastSong] => FirstSongSelected","FirstSongSelected", cdPlayer3,cdPlayer3.getItemList().length,cdPlayer3.getSongByNumber(0)) ); } @@ -228,4 +228,19 @@ class CDPlayerTest { Arguments.of("[getActualPlayTrack() after 1x prev() starting by firstSong] => FirstSongSelected", "StartingByFirstSong", cdPlayer1, 1, cdPlayer1.getSongByNumber(0)) ); } + + @ParameterizedTest + @MethodSource("getOptionsTestData") + void getOptionsTest(String testName,String testDirection, CDPlayer _cdPlayer, String expectedResult){ + assertThat(_cdPlayer.getOptions()).describedAs(testName).isNotEqualTo(null); + } + static Stream getOptionsTestData () { + CDPlayer cdPlayer1 = new CDPlayer(); + return Stream.of( + Arguments.of("[getOptions(): shouldNotReturnsNull] => ReturnValueNotNull", "ReturnValueNotNull", cdPlayer1,null) + ); + } + + + } \ No newline at end of file