mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 12:14:51 +00:00
refactor: health check
This commit is contained in:
1 parent
63a2740210
commit
a2e4307044
2 files changed
+3
-3
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: Health Check Pattern
|
title: Health Check
|
||||||
category: Behavioral
|
category: Behavioral
|
||||||
language: en
|
language: en
|
||||||
tag:
|
tag:
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class DatabaseTransactionHealthIndicatorTest {
|
|||||||
* returns a Health object with Status.UP.
|
* returns a Health object with Status.UP.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void whenDatabaseTransactionSucceeds_thenHealthIsUp() {
|
void whenDatabaseTransactionSucceeds_thenHealthIsUp() throws Exception {
|
||||||
CompletableFuture<Health> future = CompletableFuture.completedFuture(Health.up().build());
|
CompletableFuture<Health> future = CompletableFuture.completedFuture(Health.up().build());
|
||||||
when(asynchronousHealthChecker.performCheck(any(Supplier.class), eq(timeoutInSeconds)))
|
when(asynchronousHealthChecker.performCheck(any(Supplier.class), eq(timeoutInSeconds)))
|
||||||
.thenReturn(future);
|
.thenReturn(future);
|
||||||
@@ -104,7 +104,7 @@ class DatabaseTransactionHealthIndicatorTest {
|
|||||||
* returns a Health object with Status.DOWN.
|
* returns a Health object with Status.DOWN.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void whenDatabaseTransactionFails_thenHealthIsDown() {
|
void whenDatabaseTransactionFails_thenHealthIsDown() throws Exception {
|
||||||
CompletableFuture<Health> future = new CompletableFuture<>();
|
CompletableFuture<Health> future = new CompletableFuture<>();
|
||||||
when(asynchronousHealthChecker.performCheck(any(Supplier.class), eq(timeoutInSeconds)))
|
when(asynchronousHealthChecker.performCheck(any(Supplier.class), eq(timeoutInSeconds)))
|
||||||
.thenReturn(future);
|
.thenReturn(future);
|
||||||
|
|||||||
Reference in new issue
Block a user