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 PropertyMetaDataParserPropertyExpressionAnnotationsTest 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.PropertyExpression("${test}expression")
53 String property2();
54 }
55
56
57
58
59
60
61
62 private void runTest(final String methodNameAndPropertyName,
63 final PropertyExpression expression)
64 {
65 final Method method =
66 fetchMethod(TestProperties.class, methodNameAndPropertyName);
67 final PropertyDescriptor descriptor = uut.readDescriptor(method);
68
69 final PropertyKey expectedKey =
70 new PropertyKey(TestProperties.class.getName(),
71 methodNameAndPropertyName);
72 final PropertyType expectedType = new PropertyType(String.class);
73 final List<PropertyConstraint<?>> expectedConstraints =
74 Collections.emptyList();
75
76 checkThat(descriptor, expectedKey, expectedType, expression, null,
77 expectedConstraints);
78 }
79
80
81
82 @Test
83 public void parsesPropertySetOnType()
84 {
85 runTest("property1", PropertyExpression.NO_EXPRESSION);
86 }
87
88 @Test
89 public void favoursPropertySetOnMethodName()
90 {
91 runTest("property2", PropertyExpression.create("${test}expression"));
92 }
93 }