diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index a0956ca..3c5d333 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -202,8 +202,13 @@ public class UsbPlayer implements Device { } public boolean GoTo(String songName){ - playTrack = songName; - return true; + if(findSong(songName) != -1){ + playTrack = songName; + return true; + } + else + //playTrack = songName; + return false; } } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 9e1f4b1..daa1900 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -195,7 +195,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { void findSongTest(String testName, int inputPlay, int expectedResult) { //first case: the song is not in the Album // int songLoc1 = inputPlay.findSong("song 4"); - assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult);//songLoc1 + assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); //Second Case: the song is in the album // int songLoc2 = inputPlay.findSong("Musik 02"); assertThat(inputPlay).describedAs(testName).isEqualTo(expectedResult); @@ -223,8 +223,12 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { UsbPlayer up1 = new UsbPlayer(); up1.GoTo("Musik 03.mp3"); + UsbPlayer up2 = new UsbPlayer(); + up2.GoTo("Musik 04.mp3"); + return Stream.of( - Arguments.of("Go to Song : Musik 03.mp3 ", up1, "Musik 03.mp3") + Arguments.of("Go to Song : Musik 03.mp3 ", up1, "Musik 03.mp3"), + Arguments.of("Go to Song that is not in the Album: Musik 04.mp3 ", up2, "Musik 01.mp3") ); }