refactor: health check

This commit is contained in:
Ilkka Seppälä committed 2024-04-25 20:18:07 +03:00
1 parent 63a2740210
commit a2e4307044
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -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);