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
25 import de.smartics.properties.api.core.annotations.PropertyValueSecured;
26 import de.smartics.properties.api.core.domain.PropertyDescriptor;
27 import de.smartics.properties.spi.core.metadata.PropertyMetaDataParser;
28 import de.smartics.testdoc.annotations.Uut;
29
30
31
32
33
34 @Uut(type = PropertyMetaDataParser.class)
35 public class PropertyMetaDataParserSecuredTest extends
36 AbstractPropertyMetaDataParserTestBase
37 {
38
39
40
41
42
43
44
45
46 public interface TestProperties
47 {
48 @PropertyValueSecured
49 String secured();
50
51 @PropertyValueSecured(decrypt = true)
52 String explicitlySecured();
53
54 @PropertyValueSecured(decrypt = false)
55 String noDecryption();
56
57 String plain();
58 }
59
60
61
62
63
64
65
66 private void runTest(final String methodName, final boolean expected)
67 {
68 final Method method = fetchMethod(TestProperties.class, methodName);
69 final PropertyDescriptor descriptor = uut.readDescriptor(method);
70 assertThat(descriptor.isSecured(), is(expected));
71 }
72
73
74
75 @Test
76 public void recognizesSecuredProperties()
77 {
78 runTest("secured", true);
79 }
80
81 @Test
82 public void recognizesExplicitlySecuredProperties()
83 {
84 runTest("explicitlySecured", true);
85 }
86
87 @Test
88 public void recognizesNoDecryptedProperties()
89 {
90 runTest("noDecryption", false);
91 }
92
93 @Test
94 public void recognizesNonSecuredProperties()
95 {
96 runTest("plain", false);
97 }
98 }