From 652561c274e98033730c7c85c2fa852c695bb865 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 1 Sep 2020 11:50:14 +0200 Subject: [PATCH] Review checkstyle rule to prevent non BDD mockito imports Closes gh-20902 --- .../hazelcast/Hazelcast4HazelcastHealthIndicatorTests.java | 4 ++-- .../boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java | 4 ++-- src/checkstyle/checkstyle.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/Hazelcast4HazelcastHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/Hazelcast4HazelcastHealthIndicatorTests.java index a6c587c1e5d..f6d3076c0f1 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/Hazelcast4HazelcastHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/Hazelcast4HazelcastHealthIndicatorTests.java @@ -31,7 +31,7 @@ import org.springframework.core.io.ClassPathResource; 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; /** @@ -63,7 +63,7 @@ class Hazelcast4HazelcastHealthIndicatorTests { @Test void hazelcastDown() { HazelcastInstance hazelcast = mock(HazelcastInstance.class); - when(hazelcast.executeTransaction(any())).thenThrow(new HazelcastException()); + given(hazelcast.executeTransaction(any())).willThrow(new HazelcastException()); Health health = new HazelcastHealthIndicator(hazelcast).health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); } 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 92213328016..ad911800527 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 @@ -29,7 +29,7 @@ import org.springframework.core.io.ClassPathResource; 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; /** @@ -59,7 +59,7 @@ class HazelcastHealthIndicatorTests { @Test void hazelcastDown() { HazelcastInstance hazelcast = mock(HazelcastInstance.class); - when(hazelcast.executeTransaction(any())).thenThrow(new HazelcastException()); + given(hazelcast.executeTransaction(any())).willThrow(new HazelcastException()); Health health = new HazelcastHealthIndicator(hazelcast).health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); } diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index d3d713cf8bf..23dad190e39 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -41,9 +41,9 @@ - + + value="Please use BDD-style (given, when, then) using BDDMockito imports." />