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 java.lang.reflect.Method;
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.junit.Test;
23
24 import de.smartics.properties.api.core.domain.PropertyConstraint;
25 import de.smartics.properties.api.core.domain.PropertyDescriptor;
26 import de.smartics.properties.api.core.domain.PropertyExpression;
27 import de.smartics.properties.api.core.domain.PropertyKey;
28 import de.smartics.properties.api.core.domain.PropertyType;
29 import de.smartics.properties.spi.core.metadata.PropertyMetaDataParser;
30 import de.smartics.testdoc.annotations.Uut;
31
32
33
34
35
36 @Uut(type = PropertyMetaDataParser.class)
37 public class PropertyMetaDataParserPropertyKeyAnnotationsTest extends
38 AbstractPropertyMetaDataParserTestBase
39 {
40
41
42
43
44
45
46
47
48 public interface TestProperties
49 {
50 String property1();
51
52 @de.smartics.properties.api.core.annotations.PropertyKeyName("some.key")
53 String property2();
54 }
55
56
57
58
59
60
61
62 private void runTest(final String methodName, final String propertyName)
63 {
64 final Method method = fetchMethod(TestProperties.class, methodName);
65 final PropertyDescriptor descriptor = uut.readDescriptor(method);
66
67 final PropertyKey expectedKey =
68 new PropertyKey(TestProperties.class.getName(), propertyName);
69 final PropertyType expectedType = new PropertyType(String.class);
70 final List<PropertyConstraint<?>> expectedConstraints =
71 Collections.emptyList();
72
73 checkThat(descriptor, expectedKey, expectedType,
74 PropertyExpression.NO_EXPRESSION, null, expectedConstraints);
75 }
76
77
78
79 @Test
80 public void parsesPropertySetOnType()
81 {
82 runTest("property1", "property1");
83 }
84
85 @Test
86 public void favoursPropertySetOnMethodName()
87 {
88 runTest("property2", "some.key");
89 }
90 }