Untitled

 avatar
vas
plain_text
2 months ago
640 B
4
Indexable
 @Test
    void delete_shouldThrowException_whenBucketIsEmpty() {
        // Arrange
        when(awsS3ClientBuilderService.createAwsS3Client(any(), any(), any())).thenReturn(s3Client);
        when(s3Client.listObjectsV2(any(String.class))).thenReturn(null);

        // Act & Assert
        FileDownloadException exception = assertThrows(FileDownloadException.class, () -> {
            fileMgmtService.delete(AppTestConstants.BUCKET, AppTestConstants.FILENAME);
        });
        assertEquals(AppTestConstants.DELETE_FILE_ERROR_STR, exception.getMessage());
        verify(awsS3ClientBuilderService, times(1)).shutdown(s3Client);
    }
Leave a Comment