fix(metadata): NPE when updating book without files (#1446)
This commit is contained in:
+23
@@ -459,6 +459,29 @@ class MetadataManagementServiceTest {
|
||||
verify(bookRepository, never()).saveAndFlush(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeMetadataToFile_skipsWhenBookPrimaryFileIsNull() {
|
||||
LibraryPathEntity libraryPath = new LibraryPathEntity();
|
||||
libraryPath.setPath("/example");
|
||||
BookEntity book = BookEntity.builder()
|
||||
.id(1L)
|
||||
.bookFiles(List.of())
|
||||
.libraryPath(libraryPath)
|
||||
.build();
|
||||
BookMetadataEntity metadata = BookMetadataEntity.builder()
|
||||
.seriesName("Old")
|
||||
.book(book)
|
||||
.build();
|
||||
book.setMetadata(metadata);
|
||||
|
||||
when(bookMetadataRepository.findAllBySeriesNameIgnoreCase("Old")).thenReturn(List.of(metadata));
|
||||
|
||||
service.consolidateMetadata(MergeMetadataType.series, List.of("New"), List.of("Old"));
|
||||
|
||||
verify(metadataWriterFactory, never()).getWriter(any());
|
||||
verify(bookRepository, never()).saveAndFlush(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeMetadataToFile_skipsWriterWhenNoneAvailable() throws Exception {
|
||||
Path tempDir = Files.createTempDirectory("test-metadata-skip-");
|
||||
|
||||
Reference in New Issue
Block a user