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.annotations.PropertySet;
25 import de.smartics.properties.api.core.domain.PropertyConstraint;
26 import de.smartics.properties.api.core.domain.PropertyDescriptor;
27 import de.smartics.properties.api.core.domain.PropertyExpression;
28 import de.smartics.properties.api.core.domain.PropertyKey;
29 import de.smartics.properties.api.core.domain.PropertyType;
30 import de.smartics.properties.spi.core.metadata.PropertyMetaDataParser;
31 import de.smartics.testdoc.annotations.Uut;
32
33
34
35
36
37 @Uut(type = PropertyMetaDataParser.class)
38 public class PropertyMetaDataParserPropertySetAnnotationsTest extends
39 AbstractPropertyMetaDataParserTestBase
40 {
41
42
43
44
45
46
47
48
49 @PropertySet("type")
50 public interface TestProperties
51 {
52 String property1();
53
54 @PropertySet("method")
55 String property2();
56
57 @PropertySet("")
58 String property3();
59
60 @PropertySet(" ")
61 String property4();
62 }
63
64
65
66
67
68
69
70 private void runTest(final String propertySet,
71 final String methodNameAndPropertyName)
72 {
73 final Method method =
74 fetchMethod(TestProperties.class, methodNameAndPropertyName);
75 final PropertyDescriptor descriptor = uut.readDescriptor(method);
76
77 final PropertyKey expectedKey =
78 new PropertyKey(propertySet, methodNameAndPropertyName);
79 final PropertyType expectedType = new PropertyType(String.class);
80 final List<PropertyConstraint<?>> expectedConstraints =
81 Collections.emptyList();
82
83 checkThat(descriptor, expectedKey, expectedType,
84 PropertyExpression.NO_EXPRESSION, null, expectedConstraints);
85 }
86
87
88
89 @Test
90 public void parsesPropertySetOnType()
91 {
92 runTest("type", "property1");
93 }
94
95 @Test
96 public void favoursPropertySetOnMethodName()
97 {
98 runTest("method", "property2");
99 }
100
101 @Test
102 public void allowsToEraseThePropertySetName()
103 {
104 runTest(null, "property3");
105 }
106
107 @Test
108 public void defaultIsASingleSpace()
109 {
110 runTest(TestProperties.class.getName(), "property4");
111 }
112 }