feat(api, build): Upgrade to Java 25, Gradle 9, and Spring Boot 4, Jackson 3 (#2597)

* refactor: simplify RestTemplate and ObjectMapper configurations, add no-args constructors to progress classes

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* chore: update Gradle and Java versions in Docker configuration and build files

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* test: enhance header assertions in tests and add spring-boot-test-autoconfigure dependency

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor(tests): migrate to SpringBootTest and update entity management in test cases

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* test: update test property configurations for H2 database in Healthcheck and BookOpds repository tests

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* test: clean up HealthcheckControllerTest by removing unnecessary whitespace and comments

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* test: remove unnecessary whitespace in HealthcheckControllerTest

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* chore: downgrade Flyway version from 12.0.0 to 11.14.1 in build.gradle

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* chore: downgrade Flyway version from 12.0.0 to 11.14.1 in build.gradle

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add @DependsOn annotation for Flyway in MultipartConfig

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add @DependsOn annotation for Flyway in LibraryService

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add test configuration for Flyway in HealthcheckControllerTest
chore: remove unused path variable in deleteLibrary method of LibraryService

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: configure Flyway migration and update test configuration

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: enable remote debugging in bootRun configuration

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: update Flyway version and enhance ObjectMapper configuration

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: remove @DependsOn annotation for Flyway in MultipartConfig and LibraryService

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add NoArgsConstructor and AllArgsConstructor annotations to DTO classes

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add NoArgsConstructor and AllArgsConstructor annotations to FileProcessResult, MetadataUpdateContext, and MetadataUpdateWrapper classes

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add DependsOnDatabaseInitialization annotation to MultipartConfig, AppSettingService, LibraryService, and JwtSecretService classes

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add DependsOnDatabaseInitialization annotation to MultipartConfig and CronService classes

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: implement lazy initialization and thread safety for JWT secret retrieval

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add Flyway dependency and update LibraryService initialization to use ApplicationReadyEvent

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor: remove outdated comments from JwtSecretService class

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor: migrate from com.fasterxml.jackson to tools.jackson for JSON processing

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor: remove unused ObjectMapper bean and related imports from JacksonConfig

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: configure async support with VirtualThreadTaskExecutor in WebMvcConfig

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: enhance application performance with virtual threads and HTTP/2 support

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add JsonSetter annotation to skip null values for triggeredByCron field

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: add triggeredByCron field to TaskCreateRequest and initialize in task management

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* feat: enable Spring Data web support with DTO serialization in WebMvcConfig

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor(UserDefaultsService): simplify class structure and remove unused methods

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor(BookOpdsRepositoryDataJpaTest): simplify test setup and use TestEntityManager

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor(BookOpdsRepositoryDataJpaTest): update test configuration and simplify entity persistence

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor: update Jackson dependencies and migrate to Jackson 3

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor(build.gradle): update jackson-annotations dependency to use Jackson 3 BOM

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor(BookOpdsRepositoryDataJpaTest): remove unused ObjectMapper bean definition

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

* refactor(LibraryService): simplify library deletion logic

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>

---------

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
Balázs Szücs
2026-02-08 10:15:16 -07:00
committed by GitHub
parent e462b6c197
commit 108d94c0f7
147 changed files with 771 additions and 518 deletions
@@ -2,10 +2,10 @@ package org.booklore.config;
import org.booklore.context.KomgaCleanContext;
import org.booklore.model.dto.komga.KomgaBookMetadataDto;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
@@ -21,7 +21,7 @@ class KomgaCleanFilterTest {
void setup() {
// Create ObjectMapper with our custom configuration
JacksonConfig config = new JacksonConfig();
objectMapper = config.komgaCleanObjectMapper(new org.springframework.http.converter.json.Jackson2ObjectMapperBuilder());
objectMapper = config.komgaCleanObjectMapper();
}
@AfterEach
@@ -2,10 +2,10 @@ package org.booklore.config;
import org.booklore.context.KomgaCleanContext;
import org.booklore.model.dto.komga.KomgaSeriesMetadataDto;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.ObjectMapper;
import java.util.ArrayList;
@@ -22,7 +22,7 @@ class KomgaCleanModeDemo {
@BeforeEach
void setup() {
JacksonConfig config = new JacksonConfig();
objectMapper = config.komgaCleanObjectMapper(new org.springframework.http.converter.json.Jackson2ObjectMapperBuilder());
objectMapper = config.komgaCleanObjectMapper();
}
@AfterEach
@@ -1,103 +0,0 @@
package org.booklore.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.test.context.TestPropertySource; // Added this import
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(
controllers = HealthcheckController.class,
useDefaultFilters = false, // Set to false to disable default component filters
includeFilters = @ComponentScan.Filter( // Explicitly include HealthcheckController
type = FilterType.ASSIGNABLE_TYPE,
classes = HealthcheckController.class
)
)
@TestPropertySource(properties = {"app.version=1.0.0"}) // Added this line
public class HealthcheckControllerTest {
@Autowired
private MockMvc mockMvc;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private WebApplicationContext webApplicationContext;
@BeforeEach
public void setup() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Test
public void getPing_ShouldReturnHealthcheckResponse() throws Exception {
mockMvc.perform(get("/api/v1/healthcheck"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.data.status").value("UP"))
.andExpect(jsonPath("$.data.message").value("Application is running smoothly."))
.andExpect(jsonPath("$.data.timestamp").exists())
.andExpect(jsonPath("$.data.version").value("1.0.0"));
}
}
@@ -1,32 +1,71 @@
package org.booklore.repository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.booklore.model.entity.BookEntity;
import org.booklore.model.entity.BookMetadataEntity;
import org.booklore.model.entity.LibraryEntity;
import org.booklore.model.entity.LibraryPathEntity;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest
@SpringBootTest(classes = {
org.booklore.BookloreApplication.class
})
@Transactional
@TestPropertySource(properties = {
"spring.flyway.enabled=false",
"spring.jpa.hibernate.ddl-auto=create-drop"
"spring.jpa.hibernate.ddl-auto=create-drop",
"spring.jpa.database-platform=org.hibernate.dialect.H2Dialect",
"spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect",
"spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1",
"spring.datasource.driver-class-name=org.h2.Driver",
"spring.datasource.username=sa",
"spring.datasource.password=",
"app.path-config=build/tmp/test-config",
"app.bookdrop-folder=build/tmp/test-bookdrop",
"spring.main.allow-bean-definition-overriding=true",
"spring.task.scheduling.enabled=false",
"app.task.scan-library-cron=*/1 * * * * *",
"app.task.process-bookdrop-cron=*/1 * * * * *",
"app.features.oidc-enabled=false"
})
@Import(BookOpdsRepositoryDataJpaTest.TestConfig.class)
class BookOpdsRepositoryDataJpaTest {
@Autowired
private BookOpdsRepository bookOpdsRepository;
@Autowired
private TestEntityManager entityManager;
@PersistenceContext
private EntityManager entityManager;
@org.springframework.boot.test.context.TestConfiguration
public static class TestConfig {
@Bean("flyway")
@Primary
public org.flywaydb.core.Flyway flyway() {
return org.mockito.Mockito.mock(org.flywaydb.core.Flyway.class);
}
@Bean
@Primary
public org.booklore.service.task.TaskCronService taskCronService() {
return org.mockito.Mockito.mock(org.booklore.service.task.TaskCronService.class);
}
}
@Test
void contextLoads() {
@@ -40,13 +79,15 @@ class BookOpdsRepositoryDataJpaTest {
.icon("book")
.watch(false)
.build();
library = entityManager.persistAndFlush(library);
entityManager.persist(library);
entityManager.flush();
LibraryPathEntity libraryPath = LibraryPathEntity.builder()
.library(library)
.path("/test/path")
.build();
libraryPath = entityManager.persistAndFlush(libraryPath);
entityManager.persist(libraryPath);
entityManager.flush();
BookEntity book = BookEntity.builder()
.library(library)
@@ -54,17 +95,19 @@ class BookOpdsRepositoryDataJpaTest {
.addedOn(Instant.now())
.deleted(false)
.build();
book = entityManager.persistAndFlush(book);
entityManager.persist(book);
entityManager.flush();
BookMetadataEntity metadata = BookMetadataEntity.builder()
.book(book)
.bookId(book.getId())
.title("Test Title")
.build();
entityManager.persistAndFlush(metadata);
entityManager.persist(metadata);
entityManager.flush();
List<BookEntity> result = bookOpdsRepository.findAllWithMetadataByIds(List.of(book.getId()));
assertThat(result).hasSize(1);
assertThat(result.get(0).getId()).isEqualTo(book.getId());
}
}
}
@@ -2,8 +2,8 @@ package org.booklore.service;
import org.booklore.mapper.AdditionalFileMapper;
import org.booklore.model.dto.BookFile;
import org.booklore.model.entity.BookFileEntity;
import org.booklore.model.entity.BookEntity;
import org.booklore.model.entity.BookFileEntity;
import org.booklore.model.entity.LibraryPathEntity;
import org.booklore.repository.BookAdditionalFileRepository;
import org.booklore.service.file.AdditionalFileService;
@@ -264,7 +264,7 @@ class AdditionalFileServiceTest {
assertEquals(HttpStatus.OK, result.getStatusCode());
assertNotNull(result.getBody());
assertTrue(result.getHeaders().containsKey(HttpHeaders.CONTENT_DISPOSITION));
assertNotNull(result.getHeaders().getFirst(HttpHeaders.CONTENT_DISPOSITION));
assertTrue(result.getHeaders().getFirst(HttpHeaders.CONTENT_DISPOSITION).contains("test-file.pdf"));
assertEquals(MediaType.APPLICATION_OCTET_STREAM, result.getHeaders().getContentType());
@@ -16,14 +16,14 @@ import org.booklore.service.metadata.extractor.EpubMetadataExtractor;
import org.booklore.service.metadata.extractor.MetadataExtractorFactory;
import org.booklore.service.metadata.extractor.PdfMetadataExtractor;
import org.booklore.util.FileService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.ObjectMapper;
import java.io.File;
import java.time.Instant;
@@ -31,9 +31,9 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.booklore.model.entity.BookdropFileEntity.Status.PENDING_REVIEW;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
import static org.booklore.model.entity.BookdropFileEntity.Status.PENDING_REVIEW;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
@@ -172,10 +172,10 @@ class BookdropMetadataServiceTest {
when(bookdropFileRepository.findById(1L)).thenReturn(Optional.of(sampleFile));
when(appSettingService.getAppSettings()).thenReturn(new AppSettings());
when(objectMapper.readValue(anyString(), eq(BookMetadata.class)))
.thenThrow(new JsonProcessingException("Invalid JSON") {
.thenThrow(new JacksonException("Invalid JSON") {
});
assertThatThrownBy(() -> bookdropMetadataService.attachFetchedMetadata(1L))
.isInstanceOf(JsonProcessingException.class);
.isInstanceOf(JacksonException.class);
}
}
@@ -9,8 +9,8 @@ import org.booklore.model.entity.BookEntity;
import org.booklore.model.entity.BookLoreUserEntity;
import org.booklore.model.entity.KoboReadingStateEntity;
import org.booklore.model.entity.UserBookProgressEntity;
import org.booklore.model.enums.ReadStatus;
import org.booklore.model.enums.KoboReadStatus;
import org.booklore.model.enums.ReadStatus;
import org.booklore.repository.BookRepository;
import org.booklore.repository.KoboReadingStateRepository;
import org.booklore.repository.UserBookProgressRepository;
@@ -29,8 +29,7 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectMapper;
import java.time.Instant;
import java.util.List;
@@ -8,12 +8,12 @@ import org.booklore.service.NotificationService;
import org.booklore.service.file.FileMovingHelper;
import org.booklore.service.kobo.KoboAutoShelfService;
import org.booklore.service.monitoring.MonitoringRegistrationService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import tools.jackson.databind.ObjectMapper;
import java.util.Collections;
import java.util.List;
@@ -24,7 +24,6 @@ import org.booklore.service.fileprocessor.BookFileProcessorRegistry;
import org.booklore.service.kobo.KoboAutoShelfService;
import org.booklore.service.metadata.MetadataRefreshService;
import org.booklore.service.monitoring.MonitoringRegistrationService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
@@ -42,6 +41,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import tools.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.nio.file.Files;
@@ -3,8 +3,6 @@ package org.booklore.service.kobo;
import org.booklore.model.dto.BookloreSyncToken;
import org.booklore.model.dto.kobo.KoboHeaders;
import org.booklore.util.kobo.BookloreSyncTokenGenerator;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -19,6 +17,8 @@ import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.server.ResponseStatusException;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import java.lang.reflect.Field;
import java.net.http.HttpClient;
@@ -170,7 +170,7 @@ class KoboServerProxyTest {
ResponseEntity<JsonNode> response = koboServerProxy.proxyCurrentRequest(null, false);
assertThat(response).isNotNull();
assertThat(response.getHeaders()).containsKey("X-Kobo-Response");
assertThat(response.getHeaders().getFirst("X-Kobo-Response")).isNotNull();
}
@Test
@@ -6,12 +6,12 @@ import org.booklore.model.dto.request.FetchMetadataRequest;
import org.booklore.model.dto.settings.AppSettings;
import org.booklore.model.dto.settings.MetadataProviderSettings;
import org.booklore.service.appsettings.AppSettingService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import tools.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.net.http.HttpClient;
@@ -8,14 +8,14 @@ import org.booklore.model.dto.request.TaskCreateRequest;
import org.booklore.model.dto.response.CronConfig;
import org.booklore.model.dto.response.TaskCreateResponse;
import org.booklore.model.enums.TaskType;
import org.booklore.task.tasks.Task;
import org.booklore.task.TaskCancellationManager;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.booklore.task.tasks.Task;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.TaskScheduler;
import tools.jackson.databind.ObjectMapper;
import java.util.List;
import java.util.Map;
@@ -1,6 +1,6 @@
package org.booklore.service.user;
import com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectMapper;
import org.booklore.model.entity.BookLoreUserEntity;
import org.booklore.model.entity.ShelfEntity;
import org.booklore.model.enums.IconType;
@@ -1,11 +1,11 @@
package org.booklore.util.kobo;
import org.booklore.model.dto.BookloreSyncToken;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import org.junit.jupiter.api.Test;
import org.booklore.model.dto.BookloreSyncToken;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import tools.jackson.databind.ObjectMapper;
import java.util.Base64;