1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle;
21
22 import static com.google.common.truth.Truth.assertWithMessage;
23
24 import java.io.IOException;
25 import java.util.Arrays;
26 import java.util.Objects;
27 import java.util.Set;
28 import java.util.stream.Collectors;
29 import java.util.stream.Stream;
30
31 import org.junit.jupiter.api.Test;
32
33 import com.puppycrawl.tools.checkstyle.checks.header.AbstractHeaderCheck;
34 import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil;
35 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
36
37 public class XdocsPropertyTypeTest {
38
39 @Test
40 public void testAllPropertyTypesAreUsed() throws IOException {
41 final Set<PropertyType> propertyTypes = Stream.concat(
42 Stream.of(AbstractHeaderCheck.class, Checker.class),
43 CheckUtil.getCheckstyleChecks().stream())
44 .map(Class::getDeclaredFields)
45 .flatMap(Arrays::stream)
46 .map(field -> field.getAnnotation(XdocsPropertyType.class))
47 .filter(Objects::nonNull)
48 .map(XdocsPropertyType::value)
49 .collect(Collectors.toUnmodifiableSet());
50
51 assertWithMessage("All property types should be used")
52 .that(propertyTypes)
53 .containsExactlyElementsIn(PropertyType.values());
54 }
55
56 @Test
57 public void testAllPropertyTypesHaveDescription() {
58 for (PropertyType value : PropertyType.values()) {
59 assertWithMessage("Property type '%s' has no description", value)
60 .that(CommonUtil.isBlank(value.getDescription()))
61 .isFalse();
62 }
63 }
64
65 }