From d8a05090b3327f2eb52c9aa50725b767e2c4ca9c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 4 Dec 2020 18:06:54 -0800 Subject: [PATCH] Fix checkstyle BDD Mockito violations See gh-24337 --- .../hazelcast/HazelcastHealthIndicatorTests.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java index 1340e6058f..c32d78418d 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java @@ -27,7 +27,7 @@ import org.springframework.boot.actuate.health.Status; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.when; +import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; /** @@ -43,10 +43,10 @@ class HazelcastHealthIndicatorTests { @Test void hazelcastUp() { Endpoint endpoint = mock(Endpoint.class); - when(this.hazelcast.getName()).thenReturn("hz0-instance"); - when(this.hazelcast.getLocalEndpoint()).thenReturn(endpoint); - when(endpoint.getUuid()).thenReturn("7581bb2f-879f-413f-b574-0071d7519eb0"); - when(this.hazelcast.executeTransaction(any())).thenAnswer((invocation) -> { + given(this.hazelcast.getName()).willReturn("hz0-instance"); + given(this.hazelcast.getLocalEndpoint()).willReturn(endpoint); + given(endpoint.getUuid()).willReturn("7581bb2f-879f-413f-b574-0071d7519eb0"); + given(this.hazelcast.executeTransaction(any())).willAnswer((invocation) -> { TransactionalTask task = invocation.getArgument(0); return task.execute(null); }); @@ -58,7 +58,7 @@ class HazelcastHealthIndicatorTests { @Test 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(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); }