@ -1,25 +1,26 @@
package device.radioPlayer ;
import device.radioPlayer.RadioPlayer ;
import device.usbPlayer.UsbPlayer ;
import device.Device ;
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 ;
import org.junit.jupiter.params.provider.MethodSource ;
import java.lang.reflect.Method ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.List ;
import java.util.stream.Stream ;
import static org.assertj.core.api.Assertions.assertThat ;
class RadioPlayerTest {
@ParameterizedTest
@MethodSource ( "quieterLouderOptions" )
void quieterLouderTest ( String testName , RadioPlayer testRp , int expectedResult ) {
int volume = testRp . getLautstaerk e ( ) ;
int volume = testRp . getVolum e ( ) ;
assertThat ( volume ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
@ -28,13 +29,13 @@ class RadioPlayerTest {
RadioPlayer rp2 = new RadioPlayer ( ) ;
RadioPlayer rp3 = new RadioPlayer ( ) ;
RadioPlayer rp4 = new RadioPlayer ( ) ;
rp1 . setLautstaerk e ( 0 ) ;
rp1 . setVolum e ( 0 ) ;
rp1 . louder ( ) ;
rp2 . setLautstaerk e ( 100 ) ;
rp2 . setVolum e ( 100 ) ;
rp2 . louder ( ) ;
rp3 . setLautstaerk e ( 1 ) ;
rp3 . setVolum e ( 1 ) ;
rp3 . quieter ( ) ;
rp4 . setLautstaerk e ( 0 ) ;
rp4 . setVolum e ( 0 ) ;
rp4 . quieter ( ) ;
return Stream . of (
Arguments . of ( "Test for one step louder" , rp1 , 1 ) ,
@ -47,7 +48,7 @@ class RadioPlayerTest {
@ParameterizedTest
@MethodSource ( "changeRegionOptions" )
void changeRegionTest ( String testName , RadioPlayer testRp , String expectedResult ) {
String station = testRp . playTrack ;
String station = testRp . playedStation ;
assertThat ( station ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
@ -58,7 +59,6 @@ class RadioPlayerTest {
rp1 . changeRegion ( "BY" ) ;
rp2 . changeRegion ( "HE" ) ;
rp3 . changeRegion ( "BW" ) ;
return Stream . of (
Arguments . of ( "Test change Region to Bayern" , rp1 , "Antenne Bayern" ) ,
Arguments . of ( "Test change Region to Hessen" , rp2 , "Hit Radio FFH" ) ,
@ -66,69 +66,73 @@ class RadioPlayerTest {
) ;
}
/ *
@Test
void getVolume ( ) {
}
* /
@ParameterizedTest
@MethodSource ( "prevNextOptions" )
void prevNextTest ( String testName , RadioPlayer testRp , String expectedResult ) {
String station = testRp . playTrack ;
String station = testRp . playedStation ;
assertThat ( station ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
}
static Stream < Arguments > prevNextOptions ( ) {
RadioPlayer rp1 = new RadioPlayer ( ) ;
RadioPlayer rp2 = new RadioPlayer ( ) ;
RadioPlayer rp3 = new RadioPlayer ( ) ;
RadioPlayer rp4 = new RadioPlayer ( ) ;
RadioPlayer rp5 = new RadioPlayer ( ) ;
RadioPlayer rp6 = new RadioPlayer ( ) ;
rp1 . next ( ) ;
rp2 . next ( ) ;
rp2 . prev ( ) ;
rp3 . prev ( ) ;
rp4 . changeRegion ( "BY" ) ;
rp4 . next ( ) ;
rp5 . changeRegion ( "BY" ) ;
rp5 . prev ( ) ;
rp6 . changeRegion ( "BY" ) ;
rp6 . saveStation ( ) ;
rp6 . next ( ) ;
return Stream . of (
Arguments . of ( "Next Station Test" , rp1 , "Teddy" ) ,
Arguments . of ( "Prev Station Test" , rp2 , "YouFM" ) ,
Arguments . of ( "Prev works on first Station " , rp3 , "MegaHits" )
Arguments . of ( "Next Station Test for saved Stations" , rp1 , "Teddy" ) ,
Arguments . of ( "Prev Station Test for saved Stations" , rp2 , "YouFM" ) ,
Arguments . of ( "Prev works on first Station for saved Stations" , rp3 , "MegaHits" ) ,
Arguments . of ( "changed Region and going to next station" , rp4 , "Bayern 1" ) ,
Arguments . of ( "changed Region and going to prev station" , rp5 , "Hit Radio N1" ) ,
Arguments . of ( "changed Region, saved station and going to next station" , rp6 , "YouFM" )
) ;
}
@Test
void YouFMInfoByTimeTest ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
assertThat ( rp . getYouFMInfoByTime ( 8 ) ) . describedAs ( "YouFM info by Time at 8.00" ) . isEqualTo ( "YOUFM Good Morning Show" ) ;
}
@Test
void YouFMInfoByTime2Test ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
assertThat ( rp . getYouFMInfoByTime ( 3 ) ) . describedAs ( "YouFM info by Time at 3.00" ) . isEqualTo ( "YOUFM Junge Nacht der ARD" ) ;
}
@Test
void AntenneBYInfoByTimeTest ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
assertThat ( rp . getAntenneBYInfoByTime ( 8 ) ) . describedAs ( "AntenneBY info by Time at 8.00" ) . isEqualTo ( "ANTENNE BAYERN Guten Morgen Bayern" ) ;
}
@Test
void AntenneBYInfoByTime2Test ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
assertThat ( rp . getAntenneBYInfoByTime ( 3 ) ) . describedAs ( "AntenneBY info by Time at 3.00" ) . isEqualTo ( "ANTENNE BAYERN Hit-Nacht" ) ;
}
@Test
void BR3InfoByTimeTest ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
assertThat ( rp . getBR3InfoByTime ( 5 ) ) . describedAs ( "BR3 info by Time at 5.00" ) . isEqualTo ( "Sebastian Winkler und die Frühaufdreher" ) ;
@ParameterizedTest
@MethodSource ( "infoByTimeOptions" )
void infoByTimeInfo ( String testName , RadioPlayer testRp , String testTyp , int hour , String expectedResult ) {
if ( testTyp . equals ( "YouFM" ) ) assertThat ( testRp . getYouFMInfoByTime ( hour ) ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
if ( testTyp . equals ( "BR3" ) ) assertThat ( testRp . getBR3InfoByTime ( hour ) ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
if ( testTyp . equals ( "AntenneBY" ) ) assertThat ( testRp . getAntenneBYInfoByTime ( hour ) ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
@Test
void BR3InfoByTime2Test ( ) {
static Stream < Arguments > infoByTimeOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
assertThat ( rp . getBR3InfoByTime ( 21 ) ) . describedAs ( "BR3 info by Time at 21.00" ) . isEqualTo ( "Matuschke - der etwas andere Abend" ) ;
return Stream . of (
Arguments . of ( "Station info YouFm at 5:00 am" , rp , "YouFM" , 5 , rp . YouFMInfo [ 0 ] ) ,
Arguments . of ( "Station info YouFm at 10:00 am" , rp , "YouFM" , 10 , rp . YouFMInfo [ 1 ] ) ,
Arguments . of ( "Station info YouFm at 2:00 pm" , rp , "YouFM" , 14 , rp . YouFMInfo [ 2 ] ) ,
Arguments . of ( "Station info YouFm at 6:00 pm" , rp , "YouFM" , 18 , rp . YouFMInfo [ 3 ] ) ,
Arguments . of ( "Station info YouFm at 8:00 pm" , rp , "YouFM" , 20 , rp . YouFMInfo [ 4 ] ) ,
Arguments . of ( "Station info YouFm at 10:00 pm" , rp , "YouFM" , 22 , rp . YouFMInfo [ 5 ] ) ,
Arguments . of ( "Station info YouFm at 3:00 am" , rp , "YouFM" , 3 , rp . YouFMInfo [ 6 ] ) ,
Arguments . of ( "Station info BR3 at 5:00 am" , rp , "BR3" , 5 , rp . BR3Info [ 0 ] ) ,
Arguments . of ( "Station info BR3 at 9:00 am" , rp , "BR3" , 9 , rp . BR3Info [ 1 ] ) ,
Arguments . of ( "Station info BR3 at 12:00 am" , rp , "BR3" , 12 , rp . BR3Info [ 2 ] ) ,
Arguments . of ( "Station info BR3 at 1:00 pm" , rp , "BR3" , 13 , rp . BR3Info [ 3 ] ) ,
Arguments . of ( "Station info BR3 at 4:00 pm" , rp , "BR3" , 16 , rp . BR3Info [ 4 ] ) ,
Arguments . of ( "Station info BR3 at 7:00 pm" , rp , "BR3" , 19 , rp . BR3Info [ 5 ] ) ,
Arguments . of ( "Station info BR3 at 9:00 pm" , rp , "BR3" , 21 , rp . BR3Info [ 6 ] ) ,
Arguments . of ( "Station info BR3 at 3:00 am" , rp , "BR3" , 3 , rp . BR3Info [ 7 ] ) ,
Arguments . of ( "Station info AntenneBY at 5:00 am" , rp , "AntenneBY" , 5 , rp . AntenneBYInfo [ 0 ] ) ,
Arguments . of ( "Station info AntenneBY at 9:00 am" , rp , "AntenneBY" , 9 , rp . AntenneBYInfo [ 1 ] ) ,
Arguments . of ( "Station info AntenneBY at 12:00 am" , rp , "AntenneBY" , 12 , rp . AntenneBYInfo [ 2 ] ) ,
Arguments . of ( "Station info AntenneBY at 3:00 pm" , rp , "AntenneBY" , 15 , rp . AntenneBYInfo [ 3 ] ) ,
Arguments . of ( "Station info AntenneBY at 3:00 am" , rp , "AntenneBY" , 3 , rp . AntenneBYInfo [ 4 ] )
) ;
}
@ParameterizedTest
@ -148,7 +152,6 @@ class RadioPlayerTest {
rp3 . next ( ) ;
RadioPlayer rp4 = new RadioPlayer ( ) ;
rp4 . next ( ) ;
return Stream . of (
Arguments . of ( "Show Station Info for first saved Radio" , rp1 , rp1 . getYouFMInfoByTime ( rp1 . hour ) ) ,
Arguments . of ( "Show Station Info for regional Station" , rp2 , rp2 . getAntenneBYInfoByTime ( rp2 . hour ) ) ,
@ -157,23 +160,265 @@ class RadioPlayerTest {
) ;
}
/ *
@ParameterizedTest
@MethodSource ( "chooseItemOptions" )
void testChooseItem ( String testName , RadioPlayer testRp , String expectedResult ) {
String playedStation = testRp . playedStation ;
assertThat ( playedStation ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
@Test
void getInfoText ( ) {
static Stream < Arguments > chooseItemOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
rp . chooseItem ( 2 ) ;
RadioPlayer rp1 = new RadioPlayer ( ) ;
rp1 . chooseItem ( 5 ) ;
RadioPlayer rp2 = new RadioPlayer ( ) ;
rp2 . chooseItem ( - 1 ) ;
RadioPlayer rp3 = new RadioPlayer ( ) ;
rp3 . changeRegion ( "BY" ) ;
rp3 . chooseItem ( 2 ) ;
RadioPlayer rp4 = new RadioPlayer ( ) ;
rp4 . changeRegion ( "BY" ) ;
rp4 . chooseItem ( 5 ) ;
RadioPlayer rp5 = new RadioPlayer ( ) ;
rp5 . changeRegion ( "BY" ) ;
rp5 . chooseItem ( - 2 ) ;
return Stream . of (
Arguments . of ( "Test select station in saved playlist to play with nr isn`t bigger than playlist size" , rp , "Teddy" ) ,
Arguments . of ( "Test select station in saved playlist to play with nr is bigger than playlist size. Last station in playlist gets played" , rp1 , "MegaHits" ) ,
Arguments . of ( "Test select station in saved playlist to play with nr is lower than 0. First station in playlist gets played" , rp2 , "YouFM" ) ,
Arguments . of ( "Test select station in regional playlist to play with nr isn`t bigger than playlist size" , rp3 , "Bayern 1" ) ,
Arguments . of ( "Test select station in regional playlist to play with nr is bigger than playlist size. Last station in playlist gets played" , rp4 , "Hit Radio N1" ) ,
Arguments . of ( "Test select station in regional playlist to play with nr is lower than 0. Last station in playlist gets played" , rp5 , "Antenne Bayern" )
) ;
}
@Test
void getOptions ( ) {
@ParameterizedTest
@MethodSource ( "testPlayOptions" )
void testPlay ( String testName , RadioPlayer testRp , String expectedResult ) {
String playedStation = testRp . play ( ) ;
assertThat ( playedStation ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
@Test
void chooseOption ( ) {
static Stream < Arguments > testPlayOptions ( ) {
RadioPlayer rp1 = new RadioPlayer ( ) ;
RadioPlayer rp2 = new RadioPlayer ( ) ;
rp2 . changeRegion ( "BY" ) ;
return Stream . of (
Arguments . of ( "Test for playing first station on saved playlist" , rp1 , "Radio is playing station: 01 YouFM from saved playlist" ) ,
Arguments . of ( "Test for playing first station on regional playlist" , rp2 , "Radio is playing station: 01 Antenne Bayern from regional playlist" )
) ;
}
@ParameterizedTest
@MethodSource ( "saveStationOptions" )
void testSaveStation ( String testName , RadioPlayer testRp , String testTyp , String expectedResult ) {
String savedStation ;
if ( testTyp . equals ( "normal" ) ) {
savedStation = testRp . savedPlaylist . get ( testRp . savedPlaylist . size ( ) - 1 ) ;
} else savedStation = Boolean . toString ( testRp . regionPlaylist . isEmpty ( ) ) ;
assertThat ( savedStation ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
static Stream < Arguments > saveStationOptions ( ) {
RadioPlayer rp1 = new RadioPlayer ( ) ;
RadioPlayer rp2 = new RadioPlayer ( ) ;
RadioPlayer rp3 = new RadioPlayer ( ) ;
rp1 . changeRegion ( "BY" ) ;
rp1 . saveStation ( ) ;
rp2 . saveStation ( ) ;
rp3 . changeRegion ( "BY" ) ;
rp3 . saveStation ( ) ;
return Stream . of (
Arguments . of ( "Test for saving station in saved playlist" , rp1 , "normal" , "Antenne Bayern" ) ,
Arguments . of ( "Test for not saving station which is already in saved playlist" , rp2 , "normal" , "MegaHits" ) ,
Arguments . of ( "Test for after saving station jump back to saved playlist" , rp3 , "jump" , "true" )
) ;
}
@ParameterizedTest
@MethodSource ( "deleteStationOptions" )
void testDeleteStation ( String testName , RadioPlayer testRp , String testTyp , Boolean expectedResult ) {
Boolean savedStation ;
if ( testTyp . equals ( "delete" ) ) {
savedStation = testRp . savedPlaylist . contains ( "YouFM" ) ;
} else savedStation = testRp . savedPlaylist . contains ( "MegaHits" ) ;
assertThat ( savedStation ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
static Stream < Arguments > deleteStationOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
rp . deleteStation ( ) ;
RadioPlayer rp1 = new RadioPlayer ( ) ;
rp1 . deleteStation ( ) ;
rp1 . deleteStation ( ) ;
rp1 . deleteStation ( ) ;
return Stream . of (
Arguments . of ( "Test for delete station in saved playlist" , rp , "delete" , false ) ,
Arguments . of ( "Test for not delete station in saved playlist if this is the last station" , rp1 , "noDelete" , true )
) ;
}
@ParameterizedTest
@MethodSource ( "changeToSavedPlaylistOptions" )
void testChangeToSavedPlaylist ( String testName , RadioPlayer testRp , String expectedResult ) {
String savedStation = testRp . playedStation ;
assertThat ( savedStation ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
static Stream < Arguments > changeToSavedPlaylistOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
rp . changeToSavedPlaylist ( ) ;
RadioPlayer rp1 = new RadioPlayer ( ) ;
rp1 . changeRegion ( "BY" ) ;
rp1 . changeToSavedPlaylist ( ) ;
return Stream . of (
Arguments . of ( "Test for change to saved playlist when you already in saved playlist" , rp , "YouFM" ) ,
Arguments . of ( "Test for change to saved playlist when in regional playlist" , rp1 , "YouFM" )
) ;
}
@ParameterizedTest
@MethodSource ( "changeOrderInSavedPlaylistOptions" )
void testChangeOrderInSavedPlaylist ( String testName , RadioPlayer testRp , int nr , String expectedResult ) {
String savedStation = testRp . savedPlaylist . get ( nr ) ;
assertThat ( savedStation ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
static Stream < Arguments > changeOrderInSavedPlaylistOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
rp . next ( ) ;
rp . changeOrderInSavedPlaylist ( 1 ) ;
RadioPlayer rp1 = new RadioPlayer ( ) ;
rp1 . changeOrderInSavedPlaylist ( 5 ) ;
RadioPlayer rp2 = new RadioPlayer ( ) ;
rp2 . next ( ) ;
rp2 . changeOrderInSavedPlaylist ( - 1 ) ;
return Stream . of (
Arguments . of ( "Test for change order in saved playlist with nr isn`t bigger than playlist size" , rp , 0 , "Teddy" ) ,
Arguments . of ( "Test for change order in saved playlist with nr is than bigger playlist size put at the end of playlist" , rp1 , 2 , "YouFM" ) ,
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 testTyp , String [ ] expectedResult ) {
if ( testTyp . equals ( "region" ) ) {
testRp . changeRegion ( "BY" ) ;
}
String [ ] playList = testRp . getItemList ( ) ;
assertThat ( playList ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
static Stream < Arguments > getItemListOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
RadioPlayer rp1 = new RadioPlayer ( ) ;
rp1 . changeRegion ( "BY" ) ;
return Stream . of (
Arguments . of ( "Test for return saved playlist" , rp , "saved" , rp . savedPlaylist . toArray ( new String [ 0 ] ) ) ,
Arguments . of ( "Test for return regional playlist" , rp1 , "region" , rp1 . regionPlaylist . toArray ( new String [ 0 ] ) )
) ;
}
@ParameterizedTest
@MethodSource ( "muteOptions" )
void testMute ( String testName , String testTyp , RadioPlayer testRp , int expectedResult ) {
int volume ;
if ( testTyp . equals ( "actual" ) ) volume = testRp . getVolume ( ) ;
else volume = testRp . savedVolume ;
assertThat ( volume ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
static Stream < Arguments > muteOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
rp . setVolume ( 25 ) ;
rp . mute ( ) ;
RadioPlayer rp1 = new RadioPlayer ( ) ;
rp1 . setVolume ( 30 ) ;
rp1 . mute ( ) ;
return Stream . of (
Arguments . of ( "Test for mute RadioPlayer if volume is actually 0" , "actual" , rp , 0 ) ,
Arguments . of ( "Test for mute RadioPlayer if volume is saved before muting" , "saved" , rp1 , 30 )
) ;
}
@Test
void play ( ) {
void testUnmute ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
rp . setVolume ( 40 ) ;
rp . mute ( ) ;
rp . unmute ( ) ;
assertThat ( rp . getVolume ( ) ) . describedAs ( "Test if unmute is setting the saved volume" ) . isEqualTo ( rp . savedVolume ) ;
}
* /
@ParameterizedTest
@MethodSource ( "getInfoTextOptions" )
void testGetInfoText ( String testName , String testTyp , RadioPlayer testRp , boolean expectedResult ) {
Boolean bool ;
if ( testTyp . equals ( "null" ) ) bool = Strings . isNullOrEmpty ( testRp . getInfoText ( ) ) ;
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 ( "saved" ) ) bool = testRp . getInfoText ( ) . contains ( "Saved playlist" ) ;
else if ( testTyp . contains ( "savedNum" ) )
bool = testRp . getInfoText ( ) . contains ( ( "0" ) + testRp . savedPlaylist . indexOf ( testRp . playedStation ) + 1 ) ;
else if ( testTyp . contains ( "regionNum" ) )
bool = testRp . getInfoText ( ) . contains ( ( "0" ) + testRp . regionPlaylist . indexOf ( testRp . playedStation ) + 1 ) ;
else if ( testTyp . contains ( "stationInfo" ) ) bool = testRp . getInfoText ( ) . contains ( "Now playing" ) ;
else bool = testRp . getInfoText ( ) . contains ( "Now playing" ) ;
assertThat ( bool ) . describedAs ( testName ) . isEqualTo ( expectedResult ) ;
}
static Stream < Arguments > getInfoTextOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
RadioPlayer rp2 = new RadioPlayer ( ) ;
rp2 . changeRegion ( "BY" ) ;
RadioPlayer rp4 = new RadioPlayer ( ) ;
rp4 . next ( ) ;
RadioPlayer rp5 = new RadioPlayer ( ) ;
rp5 . changeRegion ( "HE" ) ;
rp5 . next ( ) ;
RadioPlayer rp6 = new RadioPlayer ( ) ;
rp6 . changeRegion ( "BY" ) ;
RadioPlayer rp7 = new RadioPlayer ( ) ;
rp7 . next ( ) ;
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" , rp , 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" , rp , true ) ,
Arguments . of ( "Test for getInfoText contains station number in saved playlist" , "savedNum" , rp4 , true ) ,
Arguments . of ( "Test for getInfoText contains station number in regional playlist" , "regionNum" , rp5 , true ) ,
Arguments . of ( "Test for getInfoText contains station info if station has one" , "stationInfo" , rp6 , true ) ,
Arguments . of ( "Test for getInfoText not contains station info if station not has one" , "noStationInfo" , rp7 , false )
) ;
}
@ParameterizedTest
@MethodSource ( "getOptionsOptions" )
void testGetOptions ( String testName , String testTyp , RadioPlayer testRp ) {
if ( testTyp . equals ( "notNull" ) ) assertThat ( testRp . getOptions ( ) ) . describedAs ( testName ) . isNotEqualTo ( null ) ;
if ( testTyp . equals ( "arrayLengthGreater0" ) )
assertThat ( testRp . getOptions ( ) . length ) . describedAs ( testName ) . isNotEqualTo ( 0 ) ;
else {
Method [ ] interfaceMethods = Device . class . getDeclaredMethods ( ) ;
List < String > deviceMethods = new ArrayList < > ( Arrays . asList ( testRp . getOptions ( ) ) ) ;
for ( Method interfaceMethod : interfaceMethods ) {
assertThat ( deviceMethods . contains ( interfaceMethod . getName ( ) ) ) . describedAs ( testName ) . isEqualTo ( true ) ;
}
}
}
static Stream < Arguments > getOptionsOptions ( ) {
RadioPlayer rp = new RadioPlayer ( ) ;
return Stream . of (
Arguments . of ( "returnValue of getOptions is not null" , "notNull" , rp ) ,
Arguments . of ( "should not return an empty array" , "arrayLengthGreater0" , rp ) ,
Arguments . of ( "Test if all methods declared in interface device are available" , "device" , rp )
) ;
}
}