Skip to content

Commit 5b936c9

Browse files
committed
Merge pull request #392 from izeye
* gh-392: Polish "Broaden Checkstyle rule for AssertJ assertion enforcement" Broaden Checkstyle rule for AssertJ assertion enforcement Closes gh-392
2 parents fdc8451 + 2909060 commit 5b936c9

File tree

5 files changed

+79
-1
lines changed

5 files changed

+79
-1
lines changed

spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/spring-checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
</module>
129129
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
130130
<property name="maximum" value="0"/>
131-
<property name="format" value="org\.junit\.(Assert|jupiter\.api\.Assertions)\.assert" />
131+
<property name="format" value="org\.junit\.(Assert|jupiter\.api\.Assertions)" />
132132
<property name="message"
133133
value="Please use AssertJ imports." />
134134
<property name="ignoreComments" value="true" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
+Please use AssertJ imports.
2+
+3 errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
+Please use AssertJ imports.
2+
+3 errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2017-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import org.junit.Assert;
18+
import org.junit.jupiter.api.Test;
19+
20+
import static org.junit.Assert.assertTrue;
21+
import static org.junit.Assert.fail;
22+
23+
/**
24+
* Import of banned org.junit.Assert.
25+
*
26+
* @author Andy Wilkinson
27+
*/
28+
public class AssertJBadAssertImport {
29+
30+
@Test
31+
void useTheImports() {
32+
assertTrue(true);
33+
Assert.assertFalse(false);
34+
fail("oops");
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2017-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import org.junit.jupiter.api.Assertions;
18+
import org.junit.jupiter.api.Test;
19+
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
21+
import static org.junit.jupiter.api.Assertions.fail;
22+
23+
/**
24+
* Import of banned org.junit.jupiter.api.Assertions.
25+
*
26+
* @author Andy Wilkinson
27+
*/
28+
public class AssertJBadAssertionsImport {
29+
30+
@Test
31+
void useTheImports() {
32+
assertTrue(true);
33+
Assertions.assertFalse(false);
34+
fail("oops");
35+
}
36+
37+
}

0 commit comments

Comments
 (0)