Skip to content

Commit

Permalink
additional test for coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Atanasov <[email protected]>
  • Loading branch information
ata-nas committed Oct 23, 2024
1 parent db7654d commit 3e5f927
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,31 @@ void test_readGzipFileUnsafe_ThrowsIOExceptionForInvalidGzipFile(final Path file
assertThatIOException().isThrownBy(() -> FileUtilities.readGzipFileUnsafe(filePath));
}

@ParameterizedTest
@MethodSource({"validGzipFiles", "validBlkFiles"})
void test_readFileBytesUnsafe_ReturnsByteArrayWithValidContentForValidPath(
final Path pathToTest, final String expectedContent) throws IOException {
final byte[] actualContent = FileUtilities.readFileBytesUnsafe(pathToTest);
assertThat(actualContent)
.isNotNull()
.isNotEmpty()
.asString()
.isNotNull()
.isNotBlank()
.isEqualTo(expectedContent);
}

@ParameterizedTest
@MethodSource("invalidFiles")
void test_readFileBytesUnsafe_ThrowsIOExceptionForInvalidPath(final Path pathToTest) {
assertThatIOException().isThrownBy(() -> FileUtilities.readFileBytesUnsafe(pathToTest));
}

@ParameterizedTest
@MethodSource({"validGzipFiles", "validBlkFiles"})
void test_readFileBytesUnsafe_ReturnsByteArrayWithValidContentForValidFile(
final Path filePath, final String expectedContent) throws IOException {
final byte[] actualContent = FileUtilities.readFileBytesUnsafe(filePath);
final File fileToTest, final String expectedContent) throws IOException {
final byte[] actualContent = FileUtilities.readFileBytesUnsafe(fileToTest);
assertThat(actualContent)
.isNotNull()
.isNotEmpty()
Expand All @@ -158,8 +178,8 @@ void test_readFileBytesUnsafe_ReturnsByteArrayWithValidContentForValidFile(

@ParameterizedTest
@MethodSource("invalidFiles")
void test_readFileBytesUnsafe_ThrowsIOExceptionForInvalidGzipFile(final Path filePath) {
assertThatIOException().isThrownBy(() -> FileUtilities.readFileBytesUnsafe(filePath));
void test_readFileBytesUnsafe_ThrowsIOExceptionForInvalidFile(final File fileToTest) {
assertThatIOException().isThrownBy(() -> FileUtilities.readFileBytesUnsafe(fileToTest));
}

private static Stream<Arguments> validGzipFiles() {
Expand Down

0 comments on commit 3e5f927

Please sign in to comment.