|
@ -2,42 +2,59 @@ package device.usbPlayer; |
|
|
|
|
|
|
|
|
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;//hasMessageMatching |
|
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
import java.util.stream.Stream; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
|
|
|
|
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; |
|
|
|
|
|
import static org.assertj.core.api.AssertionsForClassTypes.catchThrowable; |
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
|
|
|
|
|
|
|
class USB_StickTest { |
|
|
class USB_StickTest { |
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
@ParameterizedTest |
|
|
@MethodSource("getAlbumOptions") |
|
|
@MethodSource("getAlbumOptions") |
|
|
void getAlbumTest(String testName, ArrayList<String> album,int TestNr) {//, int expectedResult |
|
|
|
|
|
//int volumeNum = inputPlay.getLautstaerke(); |
|
|
|
|
|
if(TestNr == 1) |
|
|
|
|
|
assertThat(album).describedAs(testName).isNotEmpty(); |
|
|
|
|
|
|
|
|
void getAlbumTest(String testName, USB_Stick s, int TestNr) throws NoFolderFound { |
|
|
|
|
|
ArrayList<String> album =new ArrayList<String>(); |
|
|
|
|
|
|
|
|
|
|
|
if (TestNr == 1){ |
|
|
|
|
|
album = s.getAlbum(); |
|
|
|
|
|
assertThat(album).describedAs(testName).isNotEmpty();} |
|
|
|
|
|
else { |
|
|
|
|
|
// when |
|
|
|
|
|
Throwable thrown = catchThrowable(() -> s.getAlbum()); |
|
|
|
|
|
|
|
|
|
|
|
// then |
|
|
|
|
|
assertThat(thrown) |
|
|
|
|
|
.isInstanceOf(NoFolderFound.class) |
|
|
|
|
|
.hasMessageContaining("The USB Drive is empty"); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Stream<Arguments> getAlbumOptions() { |
|
|
|
|
|
USB_Stick stick = new USB_Stick(); |
|
|
|
|
|
ArrayList<String> AlbumsItems = new ArrayList<>(); |
|
|
|
|
|
AlbumsItems= stick.getAlbum(); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Stream<Arguments> getAlbumOptions() throws NoFolderFound { |
|
|
|
|
|
USB_Stick stick = new USB_Stick(); |
|
|
|
|
|
USB_Stick emptyStick = new USB_Stick(""); |
|
|
|
|
|
|
|
|
return Stream.of( |
|
|
return Stream.of( |
|
|
Arguments.of("First Album is loaded", stick.getAlbum(),1)//,something |
|
|
|
|
|
|
|
|
Arguments.of("First Album is loaded", stick, 1), |
|
|
|
|
|
Arguments.of("No Album is loaded", emptyStick, 2) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//ChangeAlbum |
|
|
//ChangeAlbum |
|
|
@ParameterizedTest |
|
|
@ParameterizedTest |
|
|
@MethodSource("ChangeAlbumOptions") |
|
|
@MethodSource("ChangeAlbumOptions") |
|
|
void ChangeAlbumTest(String testName, USB_Stick s) {//, int expectedResult |
|
|
|
|
|
|
|
|
void ChangeAlbumTest(String testName, USB_Stick s) throws NoFolderFound { |
|
|
ArrayList<String> a = new ArrayList<String>(); |
|
|
ArrayList<String> a = new ArrayList<String>(); |
|
|
a = s.getAlbum(); |
|
|
a = s.getAlbum(); |
|
|
|
|
|
|
|
|
assertThat(a).describedAs(testName).contains("File 01.txt","File 02.txt","File 03.txt"); |
|
|
|
|
|
|
|
|
assertThat(a).describedAs(testName).contains("File 01.txt", "File 02.txt", "File 03.txt"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static Stream<Arguments> ChangeAlbumOptions() { |
|
|
static Stream<Arguments> ChangeAlbumOptions() { |
|
|