Skip to content

Commit 1c2df42

Browse files
committed
Merge pull request #157 from davebarda
* gh-157: Polish "Simplify annotation handling in SpringJUnit5Check" Simplify annotation handling in SpringJUnit5Check Closes gh-157
2 parents 7b76036 + c7699d4 commit 1c2df42

File tree

1 file changed

+10
-19
lines changed
  • spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check

1 file changed

+10
-19
lines changed

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

Lines changed: 10 additions & 19 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.
@@ -43,22 +43,21 @@ public class SpringJUnit5Check extends AbstractSpringCheck {
4343
private static final List<String> TEST_ANNOTATIONS;
4444
static {
4545
Set<String> annotations = new LinkedHashSet<>();
46-
addAnnotation(annotations, JUNIT4_TEST_ANNOTATION);
47-
addAnnotation(annotations, "org.junit.jupiter.api.RepeatedTest");
48-
addAnnotation(annotations, "org.junit.jupiter.api.Test");
49-
addAnnotation(annotations, "org.junit.jupiter.api.TestFactory");
50-
addAnnotation(annotations, "org.junit.jupiter.api.TestTemplate");
51-
addAnnotation(annotations, "org.junit.jupiter.params.ParameterizedTest");
46+
annotations.add("RepeatedTest");
47+
annotations.add("Test");
48+
annotations.add("TestFactory");
49+
annotations.add("TestTemplate");
50+
annotations.add("ParameterizedTest");
5251
TEST_ANNOTATIONS = Collections.unmodifiableList(new ArrayList<>(annotations));
5352
}
5453

5554
private static final List<String> LIFECYCLE_ANNOTATIONS;
5655
static {
5756
Set<String> annotations = new LinkedHashSet<>();
58-
addAnnotation(annotations, "org.junit.jupiter.api.BeforeAll");
59-
addAnnotation(annotations, "org.junit.jupiter.api.BeforeEach");
60-
addAnnotation(annotations, "org.junit.jupiter.api.AfterAll");
61-
addAnnotation(annotations, "org.junit.jupiter.api.AfterEach");
57+
annotations.add("BeforeAll");
58+
annotations.add("BeforeEach");
59+
annotations.add("AfterAll");
60+
annotations.add("AfterEach");
6261
LIFECYCLE_ANNOTATIONS = Collections.unmodifiableList(new ArrayList<>(annotations));
6362
}
6463

@@ -75,14 +74,6 @@ public class SpringJUnit5Check extends AbstractSpringCheck {
7574
BANNED_IMPORTS = Collections.unmodifiableSet(bannedImports);
7675
}
7776

78-
private static void addAnnotation(Set<String> annotations, String annotation) {
79-
annotations.add(annotation);
80-
int lastDot = annotation.lastIndexOf(".");
81-
if (lastDot != -1) {
82-
annotations.add(annotation.substring(lastDot + 1));
83-
}
84-
}
85-
8677
private List<String> unlessImports = new ArrayList<>();
8778

8879
private final List<DetailAST> testMethods = new ArrayList<>();

0 commit comments

Comments
 (0)