Browse Source

Merge remote-tracking branch 'origin/feature-dev-BoardComputer2' into feature-dev-workingOnBordComputer

# Conflicts:
#	src/main/java/BordComputer.java
#	src/test/java/BordComputerTest.java
feature-pr-lastUpdate
JPANZO 3 years ago
parent
commit
0e9ae94aef
  1. 31
      src/main/java/BordComputer.java
  2. 6
      src/main/java/device/radioPlayer/RadioPlayer.java
  3. 5
      src/main/java/device/usbPlayer/UsbPlayer.java
  4. 96
      src/test/java/BordComputerTest.java
  5. 10
      src/test/java/device/radioPlayer/RadioPlayerTest.java

31
src/main/java/BordComputer.java

@ -1,6 +1,8 @@
import device.Device; import device.Device;
import device.cdPlayer.CD; import device.cdPlayer.CD;
import device.cdPlayer.CDPlayer; import device.cdPlayer.CDPlayer;
import device.cdPlayer.CD;
import device.cdPlayer.CDPlayer;
import device.radioPlayer.RadioPlayer; import device.radioPlayer.RadioPlayer;
import device.usbPlayer.USB_Stick; import device.usbPlayer.USB_Stick;
import device.usbPlayer.UsbPlayer; import device.usbPlayer.UsbPlayer;
@ -42,6 +44,35 @@ public class BordComputer {
} }
} }
public String changeDevice() {
Device[] tempDevices = new Device[installedDevices.length];
tempDevices[0] = installedDevices[1];
tempDevices[1] = installedDevices[2];
tempDevices[2] = installedDevices[0];
//replaces the lists
installedDevices = tempDevices;
//setting activeDevice
activeDevice = installedDevices[0];
String infoText="";
if(activeDevice instanceof CDPlayer){
CDPlayer cdPlayer=(CDPlayer) activeDevice;
String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"};
//some CDs
CD audioCD1=new CD("Audio",audioPlayList);
audioCD1.setAlbumName("Love Songs");
cdPlayer.tapOnCdFlap();
cdPlayer.setCD(audioCD1);
cdPlayer.tapOnCdFlap();
cdPlayer.setInfoText();
infoText = cdPlayer.getInfoText();
}else{
infoText=activeDevice.getInfoText()+" ist activate";
}
return infoText;
}
public String play(){ public String play(){
String itemToPlay=null; String itemToPlay=null;
try { try {

6
src/main/java/device/radioPlayer/RadioPlayer.java

@ -24,7 +24,7 @@ public class RadioPlayer implements Device {
int savedVolume; int savedVolume;
String playedStation; String playedStation;
public String getYouFMInfoByTime(int x) {
String getYouFMInfoByTime(int x) {
if (x >= 5 && x < 10) return YouFMInfo[0]; if (x >= 5 && x < 10) return YouFMInfo[0];
else if (x >= 10 && x < 14) return YouFMInfo[1]; else if (x >= 10 && x < 14) return YouFMInfo[1];
else if (x >= 14 && x < 18) return YouFMInfo[2]; else if (x >= 14 && x < 18) return YouFMInfo[2];
@ -36,7 +36,7 @@ public class RadioPlayer implements Device {
String[] YouFMInfo = {"YOUFM Good Morning Show", "YOUFM Worktime", "YOUFM am Nachmittag", "YOUFM am Abend", "YOUFM Wir feiern euch", "YOUFM Deutschrap ideal", "YOUFM Junge Nacht der ARD"}; String[] YouFMInfo = {"YOUFM Good Morning Show", "YOUFM Worktime", "YOUFM am Nachmittag", "YOUFM am Abend", "YOUFM Wir feiern euch", "YOUFM Deutschrap ideal", "YOUFM Junge Nacht der ARD"};
public String getBR3InfoByTime(int x) {
String getBR3InfoByTime(int x) {
if (x >= 5 && x < 9) return BR3Info[0]; if (x >= 5 && x < 9) return BR3Info[0];
else if (x >= 9 && x < 12) return BR3Info[1]; else if (x >= 9 && x < 12) return BR3Info[1];
else if (x == 12) return BR3Info[2]; else if (x == 12) return BR3Info[2];
@ -49,7 +49,7 @@ public class RadioPlayer implements Device {
String[] BR3Info = {"Sebastian Winkler und die Frühaufdreher", "BAYERN 3 - und DU mittendrin!", "Update", "Hits, Hits, Hits für euren Nachmittag", "Die Zwei für euren Feierabend", "Was geht?!", "Matuschke - der etwas andere Abend", "Die Nacht"}; String[] BR3Info = {"Sebastian Winkler und die Frühaufdreher", "BAYERN 3 - und DU mittendrin!", "Update", "Hits, Hits, Hits für euren Nachmittag", "Die Zwei für euren Feierabend", "Was geht?!", "Matuschke - der etwas andere Abend", "Die Nacht"};
public String getAntenneBYInfoByTime(int x) {
String getAntenneBYInfoByTime(int x) {
if (x >= 5 && x < 9) return AntenneBYInfo[0]; if (x >= 5 && x < 9) return AntenneBYInfo[0];
else if (x >= 9 && x < 12) return AntenneBYInfo[1]; else if (x >= 9 && x < 12) return AntenneBYInfo[1];
else if (x >= 12 && x < 15) return AntenneBYInfo[2]; else if (x >= 12 && x < 15) return AntenneBYInfo[2];

5
src/main/java/device/usbPlayer/UsbPlayer.java

@ -70,10 +70,7 @@ public class UsbPlayer implements Device {
super(); super();
isDefect = false; isDefect = false;
isConnected = true; isConnected = true;
/*Playlist.add("Musik 01.mp3");
Playlist.add("Musik 02.mp3");
Playlist.add("Musik 03.mp3");
playTrack = Playlist.get(0);*/
try { try {
Playlist = stick.getAlbum(); Playlist = stick.getAlbum();
} catch (NoFolderFound e) { } catch (NoFolderFound e) {

96
src/test/java/BordComputerTest.java

@ -84,6 +84,102 @@ class BordComputerTest {
return count; return count;
} }
////
@ParameterizedTest
@MethodSource("changeDeviceOptions")
void changeDeviceTest(String testName, BordComputer inputBC, Device[] oldDevices,Device prvDevice,String message ,int caseNr) {
Device[] newDevicesList = inputBC.installedDevices.clone();
if (caseNr == 1 ) {
assertThat(newDevicesList).describedAs(testName).isNotEqualTo(oldDevices);
}else if (caseNr == 2) {
Device currentDevice = inputBC.activeDevice;
assertThat(currentDevice).describedAs(testName).isNotEqualTo(prvDevice);
}else if (caseNr == 3) {
assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull();
}else if (caseNr == 4) {
assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull();
}else if (caseNr == 5) {
assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull();
}else if (caseNr == 6) {
assertThat(inputBC.changeDevice()).describedAs(testName).contains("USB Player");
}else if (caseNr == 7) {
assertThat(inputBC.changeDevice()).describedAs(testName).contains("CDPlayer");
}else if (caseNr == 8) {
assertThat(inputBC.changeDevice()).describedAs(testName).contains("playlist");
}
}
static Stream<Arguments> changeDeviceOptions() throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
//first case
BordComputer bc = new BordComputer();
bc.readConfig();
bc.setDevices();
Device[] currentDevices = new Device[bc.installedDevices.length];
currentDevices = bc.installedDevices.clone();
String m = bc.changeDevice();
//second case
BordComputer bc1 = new BordComputer();
bc1.readConfig();
bc1.setDevices();
Device prvDevice = bc1.activeDevice;
m =bc1.changeDevice();
//third case
BordComputer bc2 = new BordComputer();
bc2.readConfig();
bc2.setDevices();
m =bc2.changeDevice();
//forth case
BordComputer bc3 = new BordComputer();
bc3.readConfig();
bc3.setDevices();
m =bc3.changeDevice();
m =bc3.changeDevice(); //CDPlayer
//fifth case
BordComputer bc4 = new BordComputer();
bc4.readConfig();
bc4.setDevices();
m =bc4.changeDevice();
m =bc4.changeDevice(); //CDPlayer
m =bc4.changeDevice();
//sixth case
BordComputer bc5 = new BordComputer();
bc5.readConfig();
bc5.setDevices();
m =bc5.changeDevice();
//seventh case
BordComputer bc6 = new BordComputer();
bc6.readConfig();
bc6.setDevices();
m =bc6.changeDevice();
m =bc6.changeDevice();
//eighth case
BordComputer bc7 = new BordComputer();
bc7.readConfig();
bc7.setDevices();
m =bc7.changeDevice();
m =bc7.changeDevice();
m =bc7.changeDevice();
return Stream.of(
Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,null,"",1),
Arguments.of("The active Device should be changed ", bc1,null,prvDevice,"",2),
Arguments.of("The new Device returns a String ", bc2,null,prvDevice,bc2.activeDevice.toString(),3),
Arguments.of("The new Device returns a String ", bc3,null,prvDevice,null,4),
Arguments.of("The new Device returns a String ", bc4,null,prvDevice,null,5),
Arguments.of("The new Device returns Info ", bc5,null,prvDevice,null,6),
Arguments.of("The new Device returns Info ", bc6,null,prvDevice,null,7),
Arguments.of("The new Device returns Info ", bc6,null,prvDevice,null,8)
);
}
@ParameterizedTest @ParameterizedTest
@MethodSource("playDate") @MethodSource("playDate")
void playTest(String testName, String testCase,BordComputer bordComputer,String instanceName) { void playTest(String testName, String testCase,BordComputer bordComputer,String instanceName) {

10
src/test/java/device/radioPlayer/RadioPlayerTest.java

@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -104,9 +103,12 @@ class RadioPlayerTest {
@ParameterizedTest @ParameterizedTest
@MethodSource("infoByTimeOptions") @MethodSource("infoByTimeOptions")
void infoByTimeInfo(String testName, RadioPlayer testRp, String testTyp, int hour, String expectedResult) { 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);
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);
} }
static Stream<Arguments> infoByTimeOptions() { static Stream<Arguments> infoByTimeOptions() {

Loading…
Cancel
Save