|
@ -404,7 +404,7 @@ class CDPlayerTest { |
|
|
if(cases.equals("Case3")) { |
|
|
if(cases.equals("Case3")) { |
|
|
_cdPlayer.changePlaySource(); |
|
|
_cdPlayer.changePlaySource(); |
|
|
_cdPlayer.loadCDWechseler(cd,0); |
|
|
_cdPlayer.loadCDWechseler(cd,0); |
|
|
CD firstCD=_cdPlayer.getCdWechseler().getCDList()[0]; |
|
|
|
|
|
|
|
|
CD firstCD=_cdPlayer.getCdWechseler().getCDList().get(0); |
|
|
assertThat(firstCD).describedAs(testName).isNotEqualTo(null); |
|
|
assertThat(firstCD).describedAs(testName).isNotEqualTo(null); |
|
|
} |
|
|
} |
|
|
if(cases.equals("Case4")) { |
|
|
if(cases.equals("Case4")) { |
|
@ -428,5 +428,69 @@ class CDPlayerTest { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
|
|
@MethodSource("changeToNextCDData") |
|
|
|
|
|
void changeToNextCDTest(String testName,String cases, CDPlayer _cdPlayer,Exception exception) { |
|
|
|
|
|
if(cases.equals("Case1")) { |
|
|
|
|
|
Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.changeToNextCD()); |
|
|
|
|
|
assertEquals(ChangeCDOnlyOnCDWechselerException.class, newException.getClass()); |
|
|
|
|
|
} |
|
|
|
|
|
if(cases.equals("Case2")) { |
|
|
|
|
|
CD actualCD=_cdPlayer.getCD(); |
|
|
|
|
|
_cdPlayer.changeToNextCD(); |
|
|
|
|
|
CD nextCD=_cdPlayer.getCD(); |
|
|
|
|
|
assertThat(nextCD).describedAs(testName).isNotEqualTo(null); |
|
|
|
|
|
} |
|
|
|
|
|
if(cases.equals("Case3")) { |
|
|
|
|
|
CD actualCD=_cdPlayer.getCD(); |
|
|
|
|
|
_cdPlayer.changeToNextCD(); |
|
|
|
|
|
CD nextCD=_cdPlayer.getCD(); |
|
|
|
|
|
assertThat(nextCD.getId()==actualCD.getId()).describedAs(testName).isNotEqualTo(true); |
|
|
|
|
|
} |
|
|
|
|
|
if(cases.equals("Case4")) { |
|
|
|
|
|
CD actualCdBefore=_cdPlayer.getCD(); |
|
|
|
|
|
for (int i = 0; i <3 ; i++) { |
|
|
|
|
|
_cdPlayer.changeToNextCD(); |
|
|
|
|
|
} |
|
|
|
|
|
CD actualCdAfter=_cdPlayer.getCD(); |
|
|
|
|
|
assertThat(actualCdBefore.getId()==actualCdAfter.getId()).describedAs(testName).isEqualTo(true); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
static Stream<Arguments> changeToNextCDData () { |
|
|
|
|
|
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"}; |
|
|
|
|
|
CD audioCD1=new CD("Audio","PopMusic",audioPlayList,"XAc20044"); |
|
|
|
|
|
CD audioCD2=new CD("Audio","RockMusic",audioPlayList,"BLXPP78"); |
|
|
|
|
|
CD audioCD3=new CD("Audio","SalsaMusic",audioPlayList,"KKRP118"); |
|
|
|
|
|
|
|
|
|
|
|
CDPlayer cdPlayer1 = new CDPlayer(); |
|
|
|
|
|
|
|
|
|
|
|
CDPlayer cdPlayer2 = new CDPlayer(); |
|
|
|
|
|
cdPlayer2.changePlaySource(); |
|
|
|
|
|
cdPlayer2.loadCDWechseler(audioCD1,0); |
|
|
|
|
|
cdPlayer2.loadCDWechseler(audioCD2,1); |
|
|
|
|
|
cdPlayer2.loadCDWechseler(audioCD3,2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CDPlayer cdPlayer3 = new CDPlayer(); |
|
|
|
|
|
cdPlayer3.changePlaySource(); |
|
|
|
|
|
cdPlayer3.loadCDWechseler(audioCD1,0); |
|
|
|
|
|
cdPlayer3.loadCDWechseler(audioCD2,1); |
|
|
|
|
|
cdPlayer3.loadCDWechseler(audioCD3,2); |
|
|
|
|
|
|
|
|
|
|
|
CDPlayer cdPlayer4 = new CDPlayer(); |
|
|
|
|
|
cdPlayer4.changePlaySource(); |
|
|
|
|
|
cdPlayer4.loadCDWechseler(audioCD1,0); |
|
|
|
|
|
cdPlayer4.loadCDWechseler(audioCD2,1); |
|
|
|
|
|
cdPlayer4.loadCDWechseler(audioCD3,2); |
|
|
|
|
|
|
|
|
|
|
|
return Stream.of( |
|
|
|
|
|
Arguments.of("[changeToNextCD() by CDWechselerNotSelected ] => shouldThrowAnException", "Case1", cdPlayer1,new ChangeCDOnlyOnCDWechselerException()), |
|
|
|
|
|
Arguments.of("[changeToNextCD() checking the effect ] => loadedCDShouldNotReturnNull", "Case2", cdPlayer2,null), |
|
|
|
|
|
Arguments.of("[changeToNextCD() checking the effect 2 ] => loadedCDShouldNotHaveTheSameIdAsPrev", "Case3", cdPlayer3,null), |
|
|
|
|
|
Arguments.of("[3x changeToNextCD() changing from last to first CD] => FirstCDShouldBeTaken", "Case4", cdPlayer4,null) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |