Skip to content

Commit

Permalink
empty strings and negative numbers tests
Browse files Browse the repository at this point in the history
FIX tasks
  • Loading branch information
SirNoob97 committed Aug 5, 2022
1 parent ece5b4c commit 8a15f11
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ void test_Save_ThrowDataIntegrityViolationException_WhenFileDataIsNull() {
assertThrows(DataIntegrityViolationException.class, () -> fileRepository.save(file));
}

/**
* FIX: empty strings must be rejected
*/
@Test
void test_Save_NothingIsThrown_WhenFileNameIsEmpty() {
var fileData = fileDataRepository.save(randomFileData());
var file = randomFile();
file.setData(fileData);
file.setFileName("");

assertDoesNotThrow(() -> fileRepository.save(file));
}

@Test
void test_Save_ThrowDataIntegrityViolationException_WhenFileNameIsNull() {
var fileData = fileDataRepository.save(randomFileData());
Expand All @@ -113,6 +126,19 @@ void test_Save_ThrowDataIntegrityViolationException_WhenFileNameIsNull() {
assertThrows(DataIntegrityViolationException.class, () -> fileRepository.save(file));
}

/**
* FIX: negative numbers must be rejected
*/
@Test
void test_Save_NothingIsThrown_WhenFileSizeIsNegative() {
var fileData = fileDataRepository.save(randomFileData());
var file = randomFile();
file.setData(fileData);
file.setFileSize(-1L);

assertDoesNotThrow(() -> fileRepository.save(file));
}

@Test
void test_Save_ThrowDataIntegrityViolationException_WhenFileSizeIsNull() {
var fileData = fileDataRepository.save(randomFileData());
Expand All @@ -123,6 +149,19 @@ void test_Save_ThrowDataIntegrityViolationException_WhenFileSizeIsNull() {
assertThrows(DataIntegrityViolationException.class, () -> fileRepository.save(file));
}

/**
* FIX: empty string must be rejected
*/
@Test
void test_Save_NothingIsThrown_WhenMimeTypeIsEmpty() {
var fileData = fileDataRepository.save(randomFileData());
var file = randomFile();
file.setData(fileData);
file.setMimeType("");

assertDoesNotThrow(() -> fileRepository.save(file));
}

@Test
void test_Save_ThrowDataIntegrityViolationException_WhenMimeTypeIsNull() {
var fileData = fileDataRepository.save(randomFileData());
Expand Down

0 comments on commit 8a15f11

Please sign in to comment.