Browse Source

Merge commit '8f91aa7a6ca733738a3ed10707080eea4f812de7' into HEAD

feature-pr-getVolume
Jenkins 3 years ago
parent
commit
e066b88547
  1. 57
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 64
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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

@ -2,10 +2,13 @@ package device.radioPlayer;
import device.Device;
import java.time.LocalDateTime;
import java.util.ArrayList;
public class RadioPlayer implements Device {
private int x;
public RadioPlayer() {
super();
Playlist.add("YouFM");
@ -15,6 +18,44 @@ public class RadioPlayer implements Device {
}
ArrayList<String> Playlist=new ArrayList<String>();
LocalDateTime now = LocalDateTime.now();
int hour = now.getHour();
public String getYouFMInfoByTime(int x) {
if(x >= 5 && x <10 ) return YouFMInfo[0];
else if (x >= 10 && x < 14) return YouFMInfo[1];
else if (x >= 14 && x < 18) return YouFMInfo[2];
else if (x >= 18 && x < 20) return YouFMInfo[3];
else if (x >= 20 && x < 22) return YouFMInfo[4];
else if (x >= 22 && x <= 23) return YouFMInfo[5];
else return YouFMInfo[6];
}
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) {
if(x >= 5 && x <9) return BR3Info[0];
else if (x >= 9 && x < 12) return BR3Info[1];
else if (x == 12) return BR3Info[2];
else if (x >= 13 && x < 16) return BR3Info[3];
else if (x >= 16 && x < 19) return BR3Info[4];
else if (x >= 19 && x < 21) return BR3Info[5];
else if (x >= 21 && x < 24) return BR3Info[6];
else return BR3Info[7];
}
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) {
if(x >= 5 && x <9) return AntenneBYInfo[0];
else if (x >= 9 && x < 12) return AntenneBYInfo[1];
else if (x >= 12 && x < 15) return AntenneBYInfo[2];
else if (x >= 15 && x < 19) return AntenneBYInfo[3];
else return AntenneBYInfo[4];
}
String[] AntenneBYInfo = {"ANTENNE BAYERN Guten Morgen Bayern", "ANTENNE BAYERN bei der Arbeit", "ANTENNE BAYERN am Nachmittag", "ANTENNE BAYERN am Abend", "ANTENNE BAYERN Hit-Nacht"};
int Lautstaerke = 0;
String playTrack="";
@ -42,7 +83,7 @@ public class RadioPlayer implements Device {
Playlist.add("Hit Radio FFH");
Playlist.add("HR 1");
Playlist.add("HR 3");
Playlist.add("You FM");
Playlist.add("YouFM");
playTrack=Playlist.get(0);
break;
case "BW":
@ -114,4 +155,18 @@ public class RadioPlayer implements Device {
public String play() {
return null;
}
public String showStationInfo() {
switch (playTrack) {
case "Antenne Bayern":
return getAntenneBYInfoByTime(hour);
case "YouFM":
return getYouFMInfoByTime(hour);
case "Bayern 3":
return getBR3InfoByTime(hour);
default: return "";
}
}
}

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

@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class RadioPlayerTest {
RadioPlayer rp = new RadioPlayer();
@ParameterizedTest
@MethodSource("quieterLouderOptions")
@ -95,6 +95,68 @@ class RadioPlayerTest {
);
}
@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");
}
@Test
void BR3InfoByTime2Test() {
RadioPlayer rp = new RadioPlayer();
assertThat(rp.getBR3InfoByTime(21)).describedAs("BR3 info by Time at 21.00").isEqualTo("Matuschke - der etwas andere Abend");
}
@ParameterizedTest
@MethodSource("showStationInfoOptions")
void showStationInfo(String testName, RadioPlayer testRp, String expectedResult) {
String info = testRp.showStationInfo();
assertThat(info).describedAs(testName).isEqualTo(expectedResult);
}
static Stream<Arguments> showStationInfoOptions() {
RadioPlayer rp1 = new RadioPlayer();
RadioPlayer rp2 = new RadioPlayer();
rp2.changeRegion("BY");
RadioPlayer rp3 = new RadioPlayer();
rp3.changeRegion("BY");
rp3.next();
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)),
Arguments.of("Test for getting info text after station switching ", rp3, rp1.getBR3InfoByTime(rp3.hour)),
Arguments.of("Show info text for a station without ", rp4, "")
);
}
/*
@Test

Loading…
Cancel
Save