|
|
@ -27,7 +27,7 @@ import org.springframework.boot.actuate.health.Status;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
|
|
import static org.mockito.ArgumentMatchers.any;
|
|
|
|
import static org.mockito.BDDMockito.when;
|
|
|
|
import static org.mockito.BDDMockito.given;
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -43,10 +43,10 @@ class HazelcastHealthIndicatorTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void hazelcastUp() {
|
|
|
|
void hazelcastUp() {
|
|
|
|
Endpoint endpoint = mock(Endpoint.class);
|
|
|
|
Endpoint endpoint = mock(Endpoint.class);
|
|
|
|
when(this.hazelcast.getName()).thenReturn("hz0-instance");
|
|
|
|
given(this.hazelcast.getName()).willReturn("hz0-instance");
|
|
|
|
when(this.hazelcast.getLocalEndpoint()).thenReturn(endpoint);
|
|
|
|
given(this.hazelcast.getLocalEndpoint()).willReturn(endpoint);
|
|
|
|
when(endpoint.getUuid()).thenReturn("7581bb2f-879f-413f-b574-0071d7519eb0");
|
|
|
|
given(endpoint.getUuid()).willReturn("7581bb2f-879f-413f-b574-0071d7519eb0");
|
|
|
|
when(this.hazelcast.executeTransaction(any())).thenAnswer((invocation) -> {
|
|
|
|
given(this.hazelcast.executeTransaction(any())).willAnswer((invocation) -> {
|
|
|
|
TransactionalTask<?> task = invocation.getArgument(0);
|
|
|
|
TransactionalTask<?> task = invocation.getArgument(0);
|
|
|
|
return task.execute(null);
|
|
|
|
return task.execute(null);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -58,7 +58,7 @@ class HazelcastHealthIndicatorTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void hazelcastDown() {
|
|
|
|
void hazelcastDown() {
|
|
|
|
when(this.hazelcast.executeTransaction(any())).thenThrow(new HazelcastException());
|
|
|
|
given(this.hazelcast.executeTransaction(any())).willReturn(new HazelcastException());
|
|
|
|
Health health = new HazelcastHealthIndicator(this.hazelcast).health();
|
|
|
|
Health health = new HazelcastHealthIndicator(this.hazelcast).health();
|
|
|
|
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
|
|
|
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|