1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.tutorial.property.key;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20
21 import org.junit.Before;
22 import org.junit.Test;
23
24 import de.smartics.projectdoc.annotations.DocCategory;
25 import de.smartics.projectdoc.annotations.Document;
26 import de.smartics.projectdoc.annotations.topic.DocChapter;
27 import de.smartics.properties.api.core.domain.PropertyKey;
28 import de.smartics.properties.impl.config.classpath.ClasspathConfigurationProperties;
29 import de.smartics.properties.impl.config.classpath.ClasspathConfigurationPropertiesFactory;
30
31
32
33
34
35
36 @Document(title = "Naming Property Keys", sortKey = "basics0073")
37 @DocCategory({ "basics" })
38
39 public class PropertyKeyNamingTutorial
40 {
41 private ClasspathConfigurationProperties config;
42
43 private KeyNameProperties properties;
44
45 @Before
46 public void setUp()
47 {
48 config = createConfiguration();
49 properties = config.getProperties(KeyNameProperties.class);
50 }
51
52 private static ClasspathConfigurationProperties createConfiguration()
53 {
54 final ClasspathConfigurationPropertiesFactory factory =
55 new ClasspathConfigurationPropertiesFactory();
56 final ClasspathConfigurationProperties config = factory.create();
57 config.addClassPathProperties(KeyNameProperties.class);
58 return config;
59 }
60
61
62
63
64
65
66
67
68
69 @DocChapter
70 @Test
71 public void declarationOfAProperty()
72 {
73 final PropertyKey key = properties.storyPointPropertyKey();
74 final Integer value = properties.storyPoint();
75
76 assertThat(key.toString(), is("tutorial.property.key.story-point"));
77 assertThat(key.getName(), is("story-point"));
78 assertThat(key.getPropertySet(), is("tutorial.property.key"));
79 assertThat(value, is(1));
80 }
81 }