mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-15 22:15:02 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
1 parent
371439aeaa
commit
0ca162a55c
1863 files changed
+14403
-17632
No files matched your search
+19
-37
@@ -36,43 +36,38 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>health-check</artifactId>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<type>pom</type>
|
||||
<version>3.2.3</version>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>6.4.4.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Spring Boot Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Spring Boot Actuator for health check -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Data JPA for database access -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>6.4.4.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>4.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing Dependencies -->
|
||||
<dependency>
|
||||
@@ -85,21 +80,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.retry</groupId>
|
||||
<artifactId>spring-retry</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- JUnit Jupiter Engine for testing -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Mockito for mocking in tests -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>2.0.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- H2 for mocking database -->
|
||||
@@ -120,6 +101,7 @@
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>5.5.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
* their availability and responsiveness. For more information about health checks and their role in
|
||||
* microservice architectures, please refer to: [Microservices Health Checks
|
||||
* API]('https://microservices.io/patterns/observability/health-check-api.html').
|
||||
*
|
||||
*/
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
|
||||
@@ -37,10 +37,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* An asynchronous health checker component that executes health checks in a separate thread.
|
||||
*
|
||||
*/
|
||||
/** An asynchronous health checker component that executes health checks in a separate thread. */
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -38,10 +38,7 @@ import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* A health indicator that checks the health of the system's CPU.
|
||||
*
|
||||
*/
|
||||
/** A health indicator that checks the health of the system's CPU. */
|
||||
@Getter
|
||||
@Setter
|
||||
@Slf4j
|
||||
@@ -136,4 +133,4 @@ public class CpuHealthIndicator implements HealthIndicator {
|
||||
return Health.up().withDetails(details).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* A custom health indicator that periodically checks the health of a database and caches the
|
||||
* result. It leverages an asynchronous health checker to perform the health checks.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
|
||||
-1
@@ -41,7 +41,6 @@ import org.springframework.stereotype.Component;
|
||||
* test transaction using a retry mechanism. If the transaction succeeds after multiple attempts,
|
||||
* the health indicator returns {@link Health#up()} and logs a success message. If all retry
|
||||
* attempts fail, the health indicator returns {@link Health#down()} and logs an error message.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
|
||||
-1
@@ -44,7 +44,6 @@ import org.springframework.stereotype.Component;
|
||||
* reports the health status accordingly. It gathers information about the collection count,
|
||||
* collection time, memory pool name, and garbage collector algorithm for each garbage collector and
|
||||
* presents the details in a structured manner.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
|
||||
@@ -34,7 +34,6 @@ import lombok.Data;
|
||||
/**
|
||||
* An entity class that represents a health check record in the database. This class is used to
|
||||
* persist the results of health checks performed by the `DatabaseTransactionHealthIndicator`.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.springframework.stereotype.Repository;
|
||||
/**
|
||||
* A repository class for managing health check records in the database. This class provides methods
|
||||
* for checking the health of the database connection and performing test transactions.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Repository
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.springframework.stereotype.Component;
|
||||
* A custom health indicator that checks the memory usage of the application and reports the health
|
||||
* status accordingly. It uses an asynchronous health checker to perform the health check and a
|
||||
* configurable memory usage threshold to determine the health status.
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
|
||||
@@ -32,10 +32,7 @@ import org.springframework.retry.policy.SimpleRetryPolicy;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Configuration class for retry policies used in health check operations.
|
||||
*
|
||||
*/
|
||||
/** Configuration class for retry policies used in health check operations. */
|
||||
@Configuration
|
||||
@Component
|
||||
public class RetryConfig {
|
||||
|
||||
@@ -45,10 +45,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
/**
|
||||
* Tests for {@link AsynchronousHealthChecker}.
|
||||
*
|
||||
*/
|
||||
/** Tests for {@link AsynchronousHealthChecker}. */
|
||||
@Slf4j
|
||||
class AsynchronousHealthCheckerTest {
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@ import org.mockito.Mockito;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
/**
|
||||
* Test class for the {@link CpuHealthIndicator} class.
|
||||
*
|
||||
*/
|
||||
/** Test class for the {@link CpuHealthIndicator} class. */
|
||||
class CpuHealthIndicatorTest {
|
||||
|
||||
/** The CPU health indicator to be tested. */
|
||||
|
||||
@@ -47,10 +47,7 @@ import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Tests class< for {@link CustomHealthIndicator}. *
|
||||
*
|
||||
*/
|
||||
/** Tests class< for {@link CustomHealthIndicator}. * */
|
||||
class CustomHealthIndicatorTest {
|
||||
|
||||
/** Mocked AsynchronousHealthChecker instance. */
|
||||
|
||||
@@ -43,10 +43,7 @@ import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link DatabaseTransactionHealthIndicator} class.
|
||||
*
|
||||
*/
|
||||
/** Unit tests for the {@link DatabaseTransactionHealthIndicator} class. */
|
||||
class DatabaseTransactionHealthIndicatorTest {
|
||||
|
||||
/** Timeout value in seconds for the health check. */
|
||||
|
||||
@@ -40,10 +40,7 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
/**
|
||||
* Test class for {@link GarbageCollectionHealthIndicator}.
|
||||
*
|
||||
*/
|
||||
/** Test class for {@link GarbageCollectionHealthIndicator}. */
|
||||
class GarbageCollectionHealthIndicatorTest {
|
||||
|
||||
/** Mocked garbage collector MXBean. */
|
||||
|
||||
@@ -35,10 +35,7 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/**
|
||||
* Tests class for {@link HealthCheckRepository}.
|
||||
*
|
||||
*/
|
||||
/** Tests class for {@link HealthCheckRepository}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HealthCheckRepositoryTest {
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ import org.springframework.http.HttpStatus;
|
||||
* {"status":"DOWN","components":{"cpu":{"status":"DOWN","details":{"processCpuLoad":"100.00%", *
|
||||
* "availableProcessors":2,"systemCpuLoad":"100.00%","loadAverage":1.97,"timestamp":"2023-11-09T08:34:15.974557865Z",
|
||||
* * "error":"High system CPU load"}}} *
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootTest(
|
||||
|
||||
@@ -41,10 +41,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link MemoryHealthIndicator}.
|
||||
*
|
||||
*/
|
||||
/** Unit tests for {@link MemoryHealthIndicator}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MemoryHealthIndicatorTest {
|
||||
|
||||
|
||||
@@ -32,10 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link RetryConfig} class.
|
||||
*
|
||||
*/
|
||||
/** Unit tests for the {@link RetryConfig} class. */
|
||||
@SpringBootTest(classes = RetryConfig.class)
|
||||
class RetryConfigTest {
|
||||
|
||||
|
||||
Reference in new issue
Block a user