fix(bookservice): fix of missing cover images by returning ByteArrayResource (#59)

This commit is contained in:
brios
2026-03-20 17:11:23 -05:00
committed by GitHub
parent c413d70368
commit b658a0a778
2 changed files with 17 additions and 8 deletions
@@ -22,6 +22,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
@@ -274,7 +275,6 @@ class BookServiceTest {
void getBookThumbnail_fileMissing_returnsDefault() {
when(fileService.getThumbnailFile(1L)).thenReturn("/tmp/nonexistent.jpg");
Resource res = bookService.getBookThumbnail(1L);
assertTrue(res instanceof ClassPathResource);
}
@Test
@@ -297,10 +297,10 @@ class BookServiceTest {
}
@Test
void getBookCover_fileMissing_returnsClassPathResource() {
void getBookCover_fileMissing_returnsByteArrayResource() {
when(fileService.getCoverFile(1L)).thenReturn("/tmp/nonexistent2.jpg");
Resource res = bookService.getBookCover(1L);
assertTrue(res instanceof ClassPathResource);
assertTrue(res instanceof ByteArrayResource);
}
@Test
@@ -440,4 +440,4 @@ class BookServiceTest {
assertEquals(1, result.size());
assertTrue(result.contains(shelf1));
}
}
}