mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +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.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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ class Hazelcast4HazelcastHealthIndicatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void hazelcastDown() {
|
void hazelcastDown() {
|
||||||
HazelcastInstance hazelcast = mock(HazelcastInstance.class);
|
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();
|
Health health = new HazelcastHealthIndicator(hazelcast).health();
|
||||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
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.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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ class HazelcastHealthIndicatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void hazelcastDown() {
|
void hazelcastDown() {
|
||||||
HazelcastInstance hazelcast = mock(HazelcastInstance.class);
|
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();
|
Health health = new HazelcastHealthIndicator(hazelcast).health();
|
||||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@
|
|||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||||
<property name="maximum" value="0"/>
|
<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"
|
<property name="message"
|
||||||
value="Please use BDDMockito imports." />
|
value="Please use BDD-style (given, when, then) using BDDMockito imports." />
|
||||||
<property name="ignoreComments" value="true" />
|
<property name="ignoreComments" value="true" />
|
||||||
</module>
|
</module>
|
||||||
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck">
|
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck">
|
||||||
|
Loading…
Reference in New Issue
Block a user