@@ -122,6 +122,7 @@ public void simpleProperties() throws Exception {
122
122
.withDescription ("The name of this simple properties." )
123
123
.withDefaultValue ("boot" ).withDeprecation (null , null ));
124
124
assertThat (metadata ).has (Metadata .withProperty ("simple.flag" , Boolean .class )
125
+ .withDefaultValue (false )
125
126
.fromSource (SimpleProperties .class ).withDescription ("A simple flag." )
126
127
.withDeprecation (null , null ));
127
128
assertThat (metadata ).has (Metadata .withProperty ("simple.comparator" ));
@@ -148,27 +149,32 @@ public void simpleTypeProperties() throws Exception {
148
149
assertThat (metadata )
149
150
.has (Metadata .withProperty ("simple.type.my-byte" , Byte .class ));
150
151
assertThat (metadata )
151
- .has (Metadata .withProperty ("simple.type.my-primitive-byte" , Byte .class ));
152
+ .has (Metadata .withProperty ("simple.type.my-primitive-byte" , Byte .class )
153
+ .withDefaultValue (0 ));
152
154
assertThat (metadata )
153
155
.has (Metadata .withProperty ("simple.type.my-char" , Character .class ));
154
156
assertThat (metadata ).has (
155
157
Metadata .withProperty ("simple.type.my-primitive-char" , Character .class ));
156
158
assertThat (metadata )
157
159
.has (Metadata .withProperty ("simple.type.my-boolean" , Boolean .class ));
158
160
assertThat (metadata ).has (
159
- Metadata .withProperty ("simple.type.my-primitive-boolean" , Boolean .class ));
161
+ Metadata .withProperty ("simple.type.my-primitive-boolean" , Boolean .class )
162
+ .withDefaultValue (false ));
160
163
assertThat (metadata )
161
164
.has (Metadata .withProperty ("simple.type.my-short" , Short .class ));
162
165
assertThat (metadata ).has (
163
- Metadata .withProperty ("simple.type.my-primitive-short" , Short .class ));
166
+ Metadata .withProperty ("simple.type.my-primitive-short" , Short .class )
167
+ .withDefaultValue (0 ));
164
168
assertThat (metadata )
165
169
.has (Metadata .withProperty ("simple.type.my-integer" , Integer .class ));
166
170
assertThat (metadata ).has (
167
- Metadata .withProperty ("simple.type.my-primitive-integer" , Integer .class ));
171
+ Metadata .withProperty ("simple.type.my-primitive-integer" , Integer .class )
172
+ .withDefaultValue (0 ));
168
173
assertThat (metadata )
169
174
.has (Metadata .withProperty ("simple.type.my-long" , Long .class ));
170
175
assertThat (metadata )
171
- .has (Metadata .withProperty ("simple.type.my-primitive-long" , Long .class ));
176
+ .has (Metadata .withProperty ("simple.type.my-primitive-long" , Long .class )
177
+ .withDefaultValue (0 ));
172
178
assertThat (metadata )
173
179
.has (Metadata .withProperty ("simple.type.my-double" , Double .class ));
174
180
assertThat (metadata ).has (
@@ -230,7 +236,7 @@ public void deprecatedOnUnrelatedSetter() throws Exception {
230
236
.withNoDeprecation ().fromSource (type ));
231
237
assertThat (metadata )
232
238
.has (Metadata .withProperty ("not.deprecated.flag" , Boolean .class )
233
- .withNoDeprecation ().fromSource (type ));
239
+ .withDefaultValue ( false ). withNoDeprecation ().fromSource (type ));
234
240
}
235
241
236
242
@ Test
@@ -239,7 +245,8 @@ public void boxingOnSetter() throws IOException {
239
245
ConfigurationMetadata metadata = compile (type );
240
246
assertThat (metadata ).has (Metadata .withGroup ("boxing" ).fromSource (type ));
241
247
assertThat (metadata ).has (
242
- Metadata .withProperty ("boxing.flag" , Boolean .class ).fromSource (type ));
248
+ Metadata .withProperty ("boxing.flag" , Boolean .class )
249
+ .withDefaultValue (false ).fromSource (type ));
243
250
assertThat (metadata ).has (
244
251
Metadata .withProperty ("boxing.counter" , Integer .class ).fromSource (type ));
245
252
}
@@ -271,7 +278,7 @@ public void simpleMethodConfig() throws Exception {
271
278
assertThat (metadata ).has (Metadata .withProperty ("foo.name" , String .class )
272
279
.fromSource (SimpleMethodConfig .Foo .class ));
273
280
assertThat (metadata ).has (Metadata .withProperty ("foo.flag" , Boolean .class )
274
- .fromSource (SimpleMethodConfig .Foo .class ));
281
+ .withDefaultValue ( false ). fromSource (SimpleMethodConfig .Foo .class ));
275
282
}
276
283
277
284
@ Test
@@ -288,7 +295,7 @@ public void methodAndClassConfig() throws Exception {
288
295
assertThat (metadata ).has (Metadata .withProperty ("conflict.name" , String .class )
289
296
.fromSource (MethodAndClassConfig .Foo .class ));
290
297
assertThat (metadata ).has (Metadata .withProperty ("conflict.flag" , Boolean .class )
291
- .fromSource (MethodAndClassConfig .Foo .class ));
298
+ .withDefaultValue ( false ). fromSource (MethodAndClassConfig .Foo .class ));
292
299
assertThat (metadata ).has (Metadata .withProperty ("conflict.value" , String .class )
293
300
.fromSource (MethodAndClassConfig .class ));
294
301
}
@@ -308,6 +315,7 @@ public void deprecatedMethodConfig() throws Exception {
308
315
.fromSource (DeprecatedMethodConfig .Foo .class )
309
316
.withDeprecation (null , null ));
310
317
assertThat (metadata ).has (Metadata .withProperty ("foo.flag" , Boolean .class )
318
+ .withDefaultValue (false )
311
319
.fromSource (DeprecatedMethodConfig .Foo .class )
312
320
.withDeprecation (null , null ));
313
321
}
@@ -323,6 +331,7 @@ public void deprecatedMethodConfigOnClass() throws Exception {
323
331
org .springframework .boot .configurationsample .method .DeprecatedClassMethodConfig .Foo .class )
324
332
.withDeprecation (null , null ));
325
333
assertThat (metadata ).has (Metadata .withProperty ("foo.flag" , Boolean .class )
334
+ .withDefaultValue (false )
326
335
.fromSource (
327
336
org .springframework .boot .configurationsample .method .DeprecatedClassMethodConfig .Foo .class )
328
337
.withDeprecation (null , null ));
@@ -857,38 +866,49 @@ public void incrementalBuild() throws Exception {
857
866
ConfigurationMetadata metadata = project .fullBuild ();
858
867
assertThat (project .getOutputFile (MetadataStore .METADATA_PATH ).exists ()).isTrue ();
859
868
assertThat (metadata ).has (
860
- Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class ));
869
+ Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class )
870
+ .withDefaultValue (0 ));
861
871
assertThat (metadata ).has (
862
- Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class ));
872
+ Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class )
873
+ .withDefaultValue (0 ));
863
874
metadata = project .incrementalBuild (BarProperties .class );
864
875
assertThat (metadata ).has (
865
- Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class ));
876
+ Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class )
877
+ .withDefaultValue (0 ));
866
878
assertThat (metadata ).has (
867
- Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class ));
879
+ Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class )
880
+ .withDefaultValue (0 ));
868
881
project .addSourceCode (BarProperties .class ,
869
882
BarProperties .class .getResourceAsStream ("BarProperties.snippet" ));
870
883
metadata = project .incrementalBuild (BarProperties .class );
871
884
assertThat (metadata ).has (Metadata .withProperty ("bar.extra" ));
872
- assertThat (metadata ).has (Metadata .withProperty ("foo.counter" ));
873
- assertThat (metadata ).has (Metadata .withProperty ("bar.counter" ));
885
+ assertThat (metadata ).has (Metadata .withProperty ("foo.counter" )
886
+ .withDefaultValue (0 ));
887
+ assertThat (metadata ).has (Metadata .withProperty ("bar.counter" )
888
+ .withDefaultValue (0 ));
874
889
project .revert (BarProperties .class );
875
890
metadata = project .incrementalBuild (BarProperties .class );
876
891
assertThat (metadata ).isNotEqualTo (Metadata .withProperty ("bar.extra" ));
877
- assertThat (metadata ).has (Metadata .withProperty ("foo.counter" ));
878
- assertThat (metadata ).has (Metadata .withProperty ("bar.counter" ));
892
+ assertThat (metadata ).has (Metadata .withProperty ("foo.counter" )
893
+ .withDefaultValue (0 ));
894
+ assertThat (metadata ).has (Metadata .withProperty ("bar.counter" )
895
+ .withDefaultValue (0 ));
879
896
}
880
897
881
898
@ Test
882
899
public void incrementalBuildAnnotationRemoved () throws Exception {
883
900
TestProject project = new TestProject (this .temporaryFolder , FooProperties .class ,
884
901
BarProperties .class );
885
902
ConfigurationMetadata metadata = project .fullBuild ();
886
- assertThat (metadata ).has (Metadata .withProperty ("foo.counter" ));
887
- assertThat (metadata ).has (Metadata .withProperty ("bar.counter" ));
903
+ assertThat (metadata ).has (Metadata .withProperty ("foo.counter" )
904
+ .withDefaultValue (0 ));
905
+ assertThat (metadata ).has (Metadata .withProperty ("bar.counter" )
906
+ .withDefaultValue (0 ));
888
907
project .replaceText (BarProperties .class , "@ConfigurationProperties" ,
889
908
"//@ConfigurationProperties" );
890
909
metadata = project .incrementalBuild (BarProperties .class );
891
- assertThat (metadata ).has (Metadata .withProperty ("foo.counter" ));
910
+ assertThat (metadata ).has (Metadata .withProperty ("foo.counter" )
911
+ .withDefaultValue (0 ));
892
912
assertThat (metadata ).isNotEqualTo (Metadata .withProperty ("bar.counter" ));
893
913
}
894
914
@@ -898,20 +918,24 @@ public void incrementalBuildTypeRenamed() throws Exception {
898
918
BarProperties .class );
899
919
ConfigurationMetadata metadata = project .fullBuild ();
900
920
assertThat (metadata ).has (
901
- Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class ));
921
+ Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class )
922
+ .withDefaultValue (0 ));
902
923
assertThat (metadata ).has (
903
- Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class ));
924
+ Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class )
925
+ .withDefaultValue (0 ));
904
926
assertThat (metadata ).doesNotHave (Metadata .withProperty ("bar.counter" )
905
927
.fromSource (RenamedBarProperties .class ));
906
928
project .delete (BarProperties .class );
907
929
project .add (RenamedBarProperties .class );
908
930
metadata = project .incrementalBuild (RenamedBarProperties .class );
909
931
assertThat (metadata ).has (
910
- Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class ));
932
+ Metadata .withProperty ("foo.counter" ).fromSource (FooProperties .class )
933
+ .withDefaultValue (0 ));
911
934
assertThat (metadata ).doesNotHave (
912
- Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class ));
935
+ Metadata .withProperty ("bar.counter" ).fromSource (BarProperties .class )
936
+ .withDefaultValue (0 ));
913
937
assertThat (metadata ).has (Metadata .withProperty ("bar.counter" )
914
- .fromSource (RenamedBarProperties .class ));
938
+ .withDefaultValue ( 0 ). fromSource (RenamedBarProperties .class ));
915
939
}
916
940
917
941
private void assertSimpleLombokProperties (ConfigurationMetadata metadata ,
0 commit comments