1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.tutorial.config.doc;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.equalTo;
20 import static org.hamcrest.Matchers.is;
21
22 import java.io.Serializable;
23 import java.util.List;
24
25 import org.junit.Before;
26 import org.junit.Test;
27
28 import de.smartics.projectdoc.annotations.DocCategory;
29 import de.smartics.projectdoc.annotations.Document;
30 import de.smartics.projectdoc.annotations.topic.DocChapter;
31 import de.smartics.properties.api.config.app.ConfigurationPropertiesFactory;
32 import de.smartics.properties.api.config.app.ConfigurationPropertiesFactoryFactory;
33 import de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement;
34 import de.smartics.properties.api.config.domain.key.ApplicationId;
35 import de.smartics.properties.api.config.domain.key.ConfigurationKey;
36 import de.smartics.properties.api.config.domain.key.EnvironmentId;
37 import de.smartics.properties.api.core.domain.PropertyComment;
38 import de.smartics.properties.api.core.domain.PropertyDescriptor;
39 import de.smartics.properties.api.core.domain.PropertyType;
40 import de.smartics.properties.api.core.domain.PropertyValueComment;
41 import de.smartics.properties.impl.config.domain.key.rtaware.TenantUserConfigurationKey;
42 import de.smartics.sandbox.agile.Priority;
43 import de.smartics.sandbox.agile.UserStoryProperties;
44
45
46
47
48 @Document(title = "Providing Configuration Keys", sortKey = "basics1100")
49 @DocCategory({ "basics" })
50
51 public class PropertyDocumentationTutorial
52 {
53 private UserStoryProperties properties;
54
55 @Before
56 public void setUp()
57 {
58 final ConfigurationPropertiesFactory factory =
59 ConfigurationPropertiesFactoryFactory.createDefaultFactory();
60
61 final ConfigurationKey<?> key =
62 new TenantUserConfigurationKey(new EnvironmentId("test"), new ApplicationId(
63 "de.smartics.sandbox", "test-application", "0.1.0"));
64 final ConfigurationPropertiesManagement config =
65 factory.createManagement(key);
66 properties = config.getProperties(UserStoryProperties.class);
67 }
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 @DocChapter
94 @Test
95 public void accessJavadocComment()
96 {
97 final PropertyDescriptor desc = properties.namePropertyDescriptor();
98
99
100 final PropertyComment comment = desc.getComment();
101 assertThat(comment.getText(), is("The name of a user story."));
102 }
103
104
105
106
107
108 @DocChapter
109 @Test
110 public void accessPropertyRangeComment()
111 {
112 final PropertyDescriptor desc = properties.storyPointPropertyDescriptor();
113
114
115 final PropertyComment comment = desc.getComment();
116 assertThat(
117 comment.getText(),
118 is("The story point stating the estimated work to implement the story."));
119 assertThat(desc.getDefaultExpression().getExpression(), is("8"));
120 }
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 @DocChapter
138 @Test
139 public void accessValueComment()
140 {
141 final PropertyDescriptor desc =
142 properties.businessPriorityPropertyDescriptor();
143
144
145 final PropertyComment comment = desc.getComment();
146 assertThat(comment.getText(),
147 is("The business priority of the user story."));
148
149
150 final PropertyType type = desc.getType();
151 assertThat(type.getType().getName(), is(equalTo(Priority.class.getName())));
152
153
154 final PropertyValueComment valueComment = comment.getValueComment();
155 assertThat(valueComment.getSummary(),
156 is("The valid priority values for user stories."
157 + " <p> Only {@link #REQUIRED required},"
158 + " {@link #VERY_IMPORTANT very important} are items that are"
159 + " necessary to be implemented. </p>"));
160
161
162 final List<Serializable> values = valueComment.getValues();
163 assertThat(
164 valueComment.getValueComment(values.get(0)),
165 is("The story is required for the final product."
166 + " <p> This and {@link #VERY_IMPORTANT} are items necessary to be implemented. </p>"));
167 assertThat(
168 valueComment.getValueComment(values.get(1)),
169 is("The story is very important for the final product."
170 + " <p> This and {@link #REQUIRED} are items necessary to be implemented. </p>"));
171 assertThat(valueComment.getValueComment(values.get(2)),
172 is("The story is a nice-to-have for the final product,"
173 + " but not relevant for the release."));
174 assertThat(valueComment.getValueComment(values.get(3)),
175 is("The story would add to the user experience of the user,"
176 + " but is not relevant for the release."));
177 assertThat(valueComment.getValueComment(values.get(4)),
178 is("The story is not necessary to be part of the release, but may"
179 + " be included if resources are available. If the product backlog"
180 + " contains only dispensable stores, the development is likely to"
181 + " come to an end. <p> The priority is available to keep stories"
182 + " in the product backlog for further references. </p>"));
183
184 }
185 }