From 63ab60371700f3b3763dded433c30a82f23980c6 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:05:25 +0100 Subject: [PATCH 1/9] added getYouFMInfoByTime() & added first Test --- src/main/java/device/radioPlayer/RadioPlayer.java | 8 ++++++++ src/test/java/device/radioPlayer/RadioPlayerTest.java | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 36d7170..b260bbd 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -16,6 +16,14 @@ public class RadioPlayer implements Device { ArrayList Playlist=new ArrayList(); + public String getYouFMInfoByTime(int x) { + if(x >= 5 && x <10 ) return YouFMInfo[0]; + 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"}; + + int Lautstaerke = 0; String playTrack=""; diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 89092ba..042ea65 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/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,11 @@ 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 From b2e104eff6d7ca24da4221ad57e1beee926585b0 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:09:05 +0100 Subject: [PATCH 2/9] added complete code for getYouFMInfoByTime() & added Test for time 3:00 am --- src/main/java/device/radioPlayer/RadioPlayer.java | 5 +++++ src/test/java/device/radioPlayer/RadioPlayerTest.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index b260bbd..1e944cf 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -18,6 +18,11 @@ public class RadioPlayer implements Device { 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]; } diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 042ea65..fe1f954 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -100,6 +100,12 @@ class RadioPlayerTest { 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 From 435e15be50bc12f5dc70623cbe3b8c105e2a796a Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:22:35 +0100 Subject: [PATCH 3/9] added getAntenneBYInfoByTime() & added Tests --- src/main/java/device/radioPlayer/RadioPlayer.java | 13 +++++++++++++ .../java/device/radioPlayer/RadioPlayerTest.java | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 1e944cf..bf24e5b 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -2,6 +2,7 @@ package device.radioPlayer; import device.Device; +import java.time.LocalDateTime; import java.util.ArrayList; public class RadioPlayer implements Device { @@ -15,6 +16,8 @@ public class RadioPlayer implements Device { } ArrayList Playlist=new ArrayList(); + LocalDateTime now = LocalDateTime.now(); + int hour = now.getHour(); public String getYouFMInfoByTime(int x) { if(x >= 5 && x <10 ) return YouFMInfo[0]; @@ -28,6 +31,16 @@ 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"}; + 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=""; diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index fe1f954..e97d7f9 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -106,6 +106,20 @@ class RadioPlayerTest { 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 From 452ccdacef4c2b74b5668aae04ae8acaf4c10f3e Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:38:58 +0100 Subject: [PATCH 4/9] added getBR3InfoByTime() & added Tests --- src/main/java/device/radioPlayer/RadioPlayer.java | 15 +++++++++++++++ .../java/device/radioPlayer/RadioPlayerTest.java | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index bf24e5b..ce419ce 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -7,6 +7,8 @@ import java.util.ArrayList; public class RadioPlayer implements Device { + private int x; + public RadioPlayer() { super(); Playlist.add("YouFM"); @@ -31,6 +33,19 @@ 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"}; + 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 >= 22 && x <= 23) return BR3Info[5]; + else return BR3Info[6]; + } + + 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]; diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index e97d7f9..124e318 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -119,6 +119,18 @@ class RadioPlayerTest { 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"); + } + /* From 64d70c3921102b3e764079375b7c0d72e5cc3789 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:42:50 +0100 Subject: [PATCH 5/9] added showStationInfo() & first test case --- src/main/java/device/radioPlayer/RadioPlayer.java | 4 ++++ .../java/device/radioPlayer/RadioPlayerTest.java | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index ce419ce..b199256 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -155,4 +155,8 @@ public class RadioPlayer implements Device { public String play() { return null; } + + public String showStationInfo() { + return getYouFMInfoByTime(hour); + } } diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 124e318..5b948f3 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -131,6 +131,20 @@ class RadioPlayerTest { 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 showStationInfoOptions() { + RadioPlayer rp1 = new RadioPlayer(); + + return Stream.of( + Arguments.of("Show Station Info for first saved Radio", rp1, rp1.getYouFMInfoByTime(rp1.hour)) + ); + } /* From 4e1a9bdfc3bb01f5b26235c9201f4fcb8c229605 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:49:55 +0100 Subject: [PATCH 6/9] added dynamic station search & time to showStationInfo() & second test case --- src/main/java/device/radioPlayer/RadioPlayer.java | 12 ++++++++++-- .../java/device/radioPlayer/RadioPlayerTest.java | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index b199256..9f928a1 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -83,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": @@ -157,6 +157,14 @@ public class RadioPlayer implements Device { } public String showStationInfo() { - return getYouFMInfoByTime(hour); + switch (playTrack) { + case "Antenne Bayern": + return getAntenneBYInfoByTime(hour); + case "YouFM": + return getYouFMInfoByTime(hour); + default: return ""; + } + + } } diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 5b948f3..2861364 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -140,9 +140,12 @@ class RadioPlayerTest { static Stream showStationInfoOptions() { RadioPlayer rp1 = new RadioPlayer(); + RadioPlayer rp2 = new RadioPlayer(); + rp2.changeRegion("BY"); return Stream.of( - Arguments.of("Show Station Info for first saved Radio", rp1, rp1.getYouFMInfoByTime(rp1.hour)) + 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)) ); } From 7b3851803e762d042f46458d0ffe202bb246a3be Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 22:01:17 +0100 Subject: [PATCH 7/9] added more options for showStationInfo() & third test case --- src/main/java/device/radioPlayer/RadioPlayer.java | 2 ++ src/test/java/device/radioPlayer/RadioPlayerTest.java | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 9f928a1..5d771c6 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -162,6 +162,8 @@ public class RadioPlayer implements Device { return getAntenneBYInfoByTime(hour); case "YouFM": return getYouFMInfoByTime(hour); + case "Bayern 3": + return getBR3InfoByTime(hour); default: return ""; } diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 2861364..5581857 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -142,10 +142,15 @@ class RadioPlayerTest { RadioPlayer rp1 = new RadioPlayer(); RadioPlayer rp2 = new RadioPlayer(); rp2.changeRegion("BY"); + RadioPlayer rp3 = new RadioPlayer(); + rp3.changeRegion("BY"); + rp3.next(); + rp3.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("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)) ); } From 966541c2e2b67e442df614deca81f5becb77393d Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 22:06:18 +0100 Subject: [PATCH 8/9] added Test for station without Info text --- src/main/java/device/radioPlayer/RadioPlayer.java | 4 ++-- src/test/java/device/radioPlayer/RadioPlayerTest.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 5d771c6..25aba84 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -40,8 +40,8 @@ public class RadioPlayer implements Device { 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 >= 22 && x <= 23) return BR3Info[5]; - else return BR3Info[6]; + else if (x >= 22 && x <= 23) 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"}; diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 5581857..7829715 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -146,11 +146,14 @@ class RadioPlayerTest { 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("Test for getting info text after station switching ", rp3, rp1.getBR3InfoByTime(rp3.hour)), + Arguments.of("Show info text for a station without ", rp4, "") ); } From 8f91aa7a6ca733738a3ed10707080eea4f812de7 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 22:12:46 +0100 Subject: [PATCH 9/9] Bugfix for BRInfoByTime --- src/main/java/device/radioPlayer/RadioPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 25aba84..e32a3d7 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -40,7 +40,7 @@ public class RadioPlayer implements Device { 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 >= 22 && x <= 23) return BR3Info[6]; + else if (x >= 21 && x < 24) return BR3Info[6]; else return BR3Info[7]; }