Skip to content

Commit c7699d4

Browse files
committed
Polish "Simplify annotation handling in SpringJUnit5Check"
See gh-157
1 parent eaaddc7 commit c7699d4

File tree

1 file changed

+22
-16
lines changed
  • spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check

1 file changed

+22
-16
lines changed

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJUnit5Check.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2019 the original author or authors.
2+
* Copyright 2017-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,23 +37,29 @@
3737
* @author Phillip Webb
3838
*/
3939
public class SpringJUnit5Check extends AbstractSpringCheck {
40+
4041
private static final String JUNIT4_TEST_ANNOTATION = "org.junit.Test";
4142

42-
private static final List<String> TEST_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(
43-
"RepeatedTest",
44-
"Test",
45-
"TestFactory",
46-
"TestTemplate",
47-
"ParameterizedTest"
48-
));
49-
50-
private static final List<String> LIFECYCLE_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(
51-
"BeforeAll",
52-
"BeforeEach",
53-
"AfterAll",
54-
"AfterEach"
55-
)
56-
);
43+
private static final List<String> TEST_ANNOTATIONS;
44+
static {
45+
Set<String> annotations = new LinkedHashSet<>();
46+
annotations.add("RepeatedTest");
47+
annotations.add("Test");
48+
annotations.add("TestFactory");
49+
annotations.add("TestTemplate");
50+
annotations.add("ParameterizedTest");
51+
TEST_ANNOTATIONS = Collections.unmodifiableList(new ArrayList<>(annotations));
52+
}
53+
54+
private static final List<String> LIFECYCLE_ANNOTATIONS;
55+
static {
56+
Set<String> annotations = new LinkedHashSet<>();
57+
annotations.add("BeforeAll");
58+
annotations.add("BeforeEach");
59+
annotations.add("AfterAll");
60+
annotations.add("AfterEach");
61+
LIFECYCLE_ANNOTATIONS = Collections.unmodifiableList(new ArrayList<>(annotations));
62+
}
5763

5864
private static final Set<String> BANNED_IMPORTS;
5965
static {

0 commit comments

Comments
 (0)