1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.spi.core.metadata;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20
21 import java.lang.reflect.Method;
22
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 import de.smartics.properties.api.core.annotations.PropertyMetaDataMethod;
27 import de.smartics.properties.api.core.annotations.PropertySet;
28 import de.smartics.properties.api.core.domain.PropertyDescriptor;
29 import de.smartics.properties.api.core.domain.PropertyKey;
30 import de.smartics.properties.spi.core.util.PropertyUtils;
31 import de.smartics.testdoc.annotations.Uut;
32 import de.smartics.testdoc.categories.Technical;
33 import de.smartics.testdoc.categories.type.Coverage;
34 import de.smartics.util.test.lang.LangTestUtils;
35
36
37
38
39 @Uut(type = PropertyUtils.class, method = "isPropertyMethod(Method)")
40 public class PropertyUtilsIsPropertyMethodTest
41 {
42
43
44
45
46
47
48
49
50 @PropertySet
51 public interface IsProperties
52 {
53 String name();
54
55 @PropertyMetaDataMethod("name")
56 PropertyDescriptor something();
57
58 String namePropertyDescriptor();
59
60 PropertyKey namePropertyKey();
61 }
62
63
64
65
66
67
68
69
70
71 @Test(expected = NullPointerException.class)
72 @Category(Technical.class)
73 public void requiresNonNullTypeForMethodTest()
74 {
75 PropertyUtils.isPropertyMethod(null);
76 }
77
78 @Test
79 public void recognizesAnnotatedPropertyDescriptorMethod() throws Exception
80 {
81 final Method method =
82 IsProperties.class.getMethod("something", new Class<?>[0]);
83 final boolean value = PropertyUtils.isPropertyMethod(method);
84 assertThat(value, is(false));
85 }
86
87 @Test
88 public void recognizesMethodWithPropertyDescriptorSuffix() throws Exception
89 {
90 final Method method =
91 IsProperties.class.getMethod("namePropertyDescriptor", new Class<?>[0]);
92 final boolean value = PropertyUtils.isPropertyMethod(method);
93 assertThat(value, is(false));
94 }
95
96 @Test
97 public void recognizesMethodWithPropertyKeySuffix() throws Exception
98 {
99 final Method method =
100 IsProperties.class.getMethod("namePropertyKey", new Class<?>[0]);
101 final boolean value = PropertyUtils.isPropertyMethod(method);
102 assertThat(value, is(false));
103 }
104
105 @Test
106 public void recognizesPropertyMethod() throws Exception
107 {
108 final Method method = IsProperties.class.getMethod("name", new Class<?>[0]);
109 final boolean value = PropertyUtils.isPropertyMethod(method);
110 assertThat(value, is(true));
111 }
112
113 @Test
114 @Category(Coverage.class)
115 public void testPrivateConstructor()
116 {
117 LangTestUtils.runPrivateConstructorTest(PropertyUtils.class);
118 }
119 }