Browse Source

BordComputer.play; instance of UsbPlayer -> after all preconditions ShouldReturnAnItemToPlay.

feature-pr-lastUpdate
JPANZO 3 years ago
parent
commit
ec49bb8a40
  1. 17
      src/main/java/BordComputer.java
  2. 2
      src/main/java/device/usbPlayer/USB_Stick.java
  3. 9
      src/test/java/BordComputerTest.java

17
src/main/java/BordComputer.java

@ -2,6 +2,7 @@ import device.Device;
import device.cdPlayer.CD;
import device.cdPlayer.CDPlayer;
import device.radioPlayer.RadioPlayer;
import device.usbPlayer.USB_Stick;
import device.usbPlayer.UsbPlayer;
import java.io.FileReader;
@ -56,20 +57,28 @@ public class BordComputer {
return null;
}
public void meetAllPreconditionForPlay(){
if(activeDevice instanceof CDPlayer) {
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 audioCD2 = new CD("Audio", "RockMusic", audioPlayList, "BLXPP78");
CDPlayer cdPlayer=(CDPlayer) activeDevice;
CDPlayer cdPlayer = (CDPlayer) activeDevice;
cdPlayer.changePlaySource();
cdPlayer.loadCDWechseler(audioCD1, 0);
cdPlayer.loadCDWechseler(audioCD2, 1);
cdPlayer.setCD(cdPlayer.getCdWechseler().getCDList().get(0));
activeDevice=cdPlayer;
activeDevice = cdPlayer;
}
if(activeDevice instanceof UsbPlayer) {
USB_Stick USBDrive = new USB_Stick();
UsbPlayer up1 = new UsbPlayer(USBDrive);
activeDevice = up1;
}
}
public void setActiveDevice(Device activeDevice) {
this.activeDevice = activeDevice;
}

2
src/main/java/device/usbPlayer/USB_Stick.java

@ -8,7 +8,7 @@ public class USB_Stick {
public ArrayList<ArrayList<String>> Folders = new ArrayList<>();
int currentAlbum ;
USB_Stick() {
public USB_Stick() {
ArrayList<String> a1 = new ArrayList<String>();
a1.add("Musik 01.mp3");
a1.add("Musik 02.mp3");

9
src/test/java/BordComputerTest.java

@ -94,6 +94,12 @@ class BordComputerTest {
bordComputer.setActiveDevice(radioPlayer);
assertThat(bordComputer.play()).describedAs(testName).isNotEqualTo(null);
}
if(testCase.equals("Case3")) {
Device usbPlayer=bordComputer.getInstanceByName(instanceName);
bordComputer.setActiveDevice(usbPlayer);
bordComputer.meetAllPreconditionForPlay();
assertThat(bordComputer.play()).describedAs(testName).isNotEqualTo(null);
}
}
static Stream<Arguments> playDate()throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
@ -101,7 +107,8 @@ class BordComputerTest {
bordComputer.readConfig();
return Stream.of(
Arguments.of("[CDPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case1",bordComputer,"CDPlayer"),
Arguments.of("[RadioPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case2",bordComputer,"RadioPlayer")
Arguments.of("[RadioPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case2",bordComputer,"RadioPlayer"),
Arguments.of("[UsbPlayer-> play(): after all preconditions are met] => ShouldReturnAnItemToPlay","Case3",bordComputer,"UsbPlayer")
);
}

Loading…
Cancel
Save