mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Review checkstyle rule to prevent non BDD mockito imports
Closes gh-20902
This commit is contained in:
parent
a341d00529
commit
652561c274
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -41,9 +41,9 @@
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||
<property name="maximum" value="0"/>
|
||||
<property name="format" value="org\.mockito\.Mockito\.(when|doThrow|doAnswer)" />
|
||||
<property name="format" value="org\.mockito\.(Mockito|BDDMockito)\.(when|doThrow|doAnswer)" />
|
||||
<property name="message"
|
||||
value="Please use BDDMockito imports." />
|
||||
value="Please use BDD-style (given, when, then) using BDDMockito imports." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck">
|
||||
|
Loading…
Reference in New Issue
Block a user