Skip to content

Commit fc959a5

Browse files
committed
Update ConfigurationPropertyTest.java
1 parent b4794e9 commit fc959a5

1 file changed

Lines changed: 46 additions & 42 deletions

File tree

microsphere-java-core/src/test/java/io/microsphere/beans/ConfigurationPropertyTest.java

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,23 @@
3737
*/
3838
class ConfigurationPropertyTest {
3939

40-
private static final String name = "test-name";
40+
private static final String TEST_NAME = "test-name";
4141

42-
private static final String value = "test-value";
42+
private static final Class<?> TEST_TYPE = Integer.class;
43+
44+
private static final String TEST_VALUE = "test-value";
4345

44-
private static final String defaultValue = "default-value";
46+
private static final String TEST_DEFAULT_VALUE = "default-value";
4547

46-
private static final Class<?> type = Integer.class;
48+
private static final String TEST_DESCRIPTION = "test-description";
4749

50+
private static final String TEST_TARGET = "target";
51+
4852
private ConfigurationProperty property;
4953

5054
@BeforeEach
5155
void setUp() {
52-
this.property = new ConfigurationProperty(name);
56+
this.property = new ConfigurationProperty(TEST_NAME);
5357
}
5458

5559
@Test
@@ -60,28 +64,28 @@ void testNull() {
6064

6165
@Test
6266
void testName() {
63-
assertEquals(name, this.property.getName());
67+
assertEquals(TEST_NAME, this.property.getName());
6468
}
6569

6670
@Test
6771
void testType() {
6872
assertEquals(String.class.getName(), this.property.getType());
69-
this.property.setType(type);
70-
assertEquals(type.getName(), this.property.getType());
73+
this.property.setType(TEST_TYPE);
74+
assertEquals(TEST_TYPE.getName(), this.property.getType());
7175
}
7276

7377
@Test
7478
void testValue() {
7579
assertNull(this.property.getValue());
76-
this.property.setValue(value);
77-
assertEquals(value, this.property.getValue());
80+
this.property.setValue(TEST_VALUE);
81+
assertEquals(TEST_VALUE, this.property.getValue());
7882
}
7983

8084
@Test
8185
void testDefaultValue() {
8286
assertNull(this.property.getDefaultValue());
83-
this.property.setDefaultValue(defaultValue);
84-
assertEquals(defaultValue, this.property.getDefaultValue());
87+
this.property.setDefaultValue(TEST_DEFAULT_VALUE);
88+
assertEquals(TEST_DEFAULT_VALUE, this.property.getDefaultValue());
8589
}
8690

8791
@Test
@@ -132,27 +136,27 @@ void testMetadata() {
132136

133137
@Test
134138
void testHashCode() {
135-
ConfigurationProperty property = new ConfigurationProperty(name);
139+
ConfigurationProperty property = new ConfigurationProperty(TEST_NAME);
136140
assertEquals(this.property.hashCode(), property.hashCode());
137141

138-
this.property.setType(type);
139-
property.setType(type);
142+
this.property.setType(TEST_TYPE);
143+
property.setType(TEST_TYPE);
140144
assertEquals(this.property.hashCode(), property.hashCode());
141145

142-
this.property.setValue(value);
143-
property.setValue(value);
146+
this.property.setValue(TEST_VALUE);
147+
property.setValue(TEST_VALUE);
144148
assertEquals(this.property.hashCode(), property.hashCode());
145149

146-
this.property.setDefaultValue(defaultValue);
147-
property.setDefaultValue(defaultValue);
150+
this.property.setDefaultValue(TEST_DEFAULT_VALUE);
151+
property.setDefaultValue(TEST_DEFAULT_VALUE);
148152
assertEquals(this.property.hashCode(), property.hashCode());
149153

150154
this.property.setRequired(true);
151155
property.setRequired(true);
152156
assertEquals(this.property.hashCode(), property.hashCode());
153157

154-
this.property.setDescription("description");
155-
property.setDescription("description");
158+
this.property.setDescription(TEST_DESCRIPTION);
159+
property.setDescription(TEST_DESCRIPTION);
156160
assertEquals(this.property.hashCode(), property.hashCode());
157161

158162
this.property.getMetadata().getTargets().add("target");
@@ -162,34 +166,34 @@ void testHashCode() {
162166

163167
@Test
164168
void testEquals() {
165-
ConfigurationProperty property = new ConfigurationProperty(name);
169+
ConfigurationProperty property = new ConfigurationProperty(TEST_NAME);
166170
assertEquals(this.property, property);
167-
assertNotEquals(this.property, new ConfigurationProperty("_" + name));
171+
assertNotEquals(this.property, new ConfigurationProperty("_" + TEST_NAME));
168172
assertNotEquals(this.property, new Object());
169173

170-
this.property.setType(type);
174+
this.property.setType(TEST_TYPE);
171175
assertNotEquals(this.property, property);
172-
property.setType(type);
176+
property.setType(TEST_TYPE);
173177
assertEquals(this.property, property);
174178

175-
this.property.setValue(value);
179+
this.property.setValue(TEST_VALUE);
176180
assertNotEquals(this.property, property);
177-
property.setValue(value);
181+
property.setValue(TEST_VALUE);
178182
assertEquals(this.property, property);
179183

180-
this.property.setDefaultValue(defaultValue);
184+
this.property.setDefaultValue(TEST_DEFAULT_VALUE);
181185
assertNotEquals(this.property, property);
182-
property.setDefaultValue(defaultValue);
186+
property.setDefaultValue(TEST_DEFAULT_VALUE);
183187
assertEquals(this.property, property);
184188

185189
this.property.setRequired(true);
186190
assertNotEquals(this.property, property);
187191
property.setRequired(true);
188192
assertEquals(this.property, property);
189193

190-
this.property.setDescription("description");
194+
this.property.setDescription(TEST_DESCRIPTION);
191195
assertNotEquals(this.property, property);
192-
property.setDescription("description");
196+
property.setDescription(TEST_DESCRIPTION);
193197
assertEquals(this.property, property);
194198

195199
this.property.getMetadata().getTargets().add("target");
@@ -200,31 +204,31 @@ void testEquals() {
200204

201205
@Test
202206
void testToString() {
203-
ConfigurationProperty property = new ConfigurationProperty(name);
207+
ConfigurationProperty property = new ConfigurationProperty(TEST_NAME);
204208
assertEquals(this.property.toString(), property.toString());
205209

206-
this.property.setType(type);
207-
property.setType(type);
210+
this.property.setType(TEST_TYPE);
211+
property.setType(TEST_TYPE);
208212
assertEquals(this.property.toString(), property.toString());
209213

210-
this.property.setValue(value);
211-
property.setValue(value);
214+
this.property.setValue(TEST_VALUE);
215+
property.setValue(TEST_VALUE);
212216
assertEquals(this.property.toString(), property.toString());
213217

214-
this.property.setDefaultValue(defaultValue);
215-
property.setDefaultValue(defaultValue);
218+
this.property.setDefaultValue(TEST_DEFAULT_VALUE);
219+
property.setDefaultValue(TEST_DEFAULT_VALUE);
216220
assertEquals(this.property.toString(), property.toString());
217221

218222
this.property.setRequired(true);
219223
property.setRequired(true);
220224
assertEquals(this.property.toString(), property.toString());
221225

222-
this.property.setDescription("description");
223-
property.setDescription("description");
226+
this.property.setDescription(TEST_DESCRIPTION);
227+
property.setDescription(TEST_DESCRIPTION);
224228
assertEquals(this.property.toString(), property.toString());
225229

226-
this.property.getMetadata().getTargets().add("target");
227-
property.getMetadata().getTargets().add("target");
230+
this.property.getMetadata().getTargets().add(TEST_TARGET);
231+
property.getMetadata().getTargets().add(TEST_TARGET);
228232
assertEquals(this.property.toString(), property.toString());
229233
}
230234
}

0 commit comments

Comments
 (0)