Browse Source

Method loadCDWechseler of CDPlayer tested on notRunning=CDWechseler -> shouldThrowAnException.

feature-pr-BordComputer-setDevices
JPANZO 3 years ago
parent
commit
29aa121c19
  1. 7
      src/main/java/device/cdPlayer/CDPlayer.java
  2. 8
      src/main/java/device/cdPlayer/exceptions/CDWechselerNotRunningException.java
  3. 16
      src/test/java/device/cdPlayer/CDPlayerTest.java

7
src/main/java/device/cdPlayer/CDPlayer.java

@ -20,7 +20,7 @@ public class CDPlayer implements Device {
private String actualPlayTrack="";
private CD loadedCD=null;
private CDWechseler cdWechseler;
private CDWechseler cdWechseler=null;
private String activeSource="CDDrive";//or CDWechseler
@Override
@ -139,6 +139,11 @@ public class CDPlayer implements Device {
return activeSource;
}
public void loadCDWechseler(List<CD>cdList){
if(cdWechseler==null||!cdWechseler.isRunning()){
throw new CDWechselerNotRunningException();
}
}
//Getters, Setters und SupportMethods
public void setCD(CD _loadedCD) {

8
src/main/java/device/cdPlayer/exceptions/CDWechselerNotRunningException.java

@ -0,0 +1,8 @@
package device.cdPlayer.exceptions;
public class CDWechselerNotRunningException extends RuntimeException {
public CDWechselerNotRunningException() {
super("CDWechseler must be active for using.");
}
}

16
src/test/java/device/cdPlayer/CDPlayerTest.java

@ -389,6 +389,22 @@ class CDPlayerTest {
);
}
@ParameterizedTest
@MethodSource("loadCDWechselerData")
void loadCDWechselerTest(String testName,String cases, CDPlayer _cdPlayer,List<CD>cdList,Exception exception) {
Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.loadCDWechseler(cdList));
assertEquals(CDWechselerNotRunningException.class, newException.getClass());
}
static Stream<Arguments> loadCDWechselerData () {
CDPlayer cdPlayer1 = new CDPlayer();
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
CD audioCD1=new CD("Audio",audioPlayList);
List<CD>CdList1=Arrays.asList(audioCD1);
return Stream.of(
Arguments.of("[loadCDWechseler() by notRunning=CDWechseler ] => shouldThrowAnException", "Case1", cdPlayer1,CdList1,new CDWechselerNotRunningException())
);
}
}
Loading…
Cancel
Save