Browse Source

cleaned up RadioPlayer and made help functions package private

feature-pr-RadioPlayer-cleanUp
Jan Ortner 3 years ago
parent
commit
8d012dd9b3
  1. 6
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 10
      src/test/java/device/radioPlayer/RadioPlayerTest.java

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];

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