23
23
import org .junit .jupiter .api .Test ;
24
24
25
25
import org .springframework .boot .configurationprocessor .json .JSONArray ;
26
+ import org .springframework .boot .configurationprocessor .json .JSONException ;
26
27
import org .springframework .boot .configurationprocessor .json .JSONObject ;
27
28
import org .springframework .boot .configurationprocessor .metadata .ConfigurationMetadata ;
28
29
import org .springframework .boot .configurationprocessor .metadata .ItemDeprecation ;
47
48
class MergeMetadataGenerationTests extends AbstractMetadataGenerationTests {
48
49
49
50
@ Test
50
- void mergingOfAdditionalProperty () throws Exception {
51
+ void mergingOfAdditionalProperty () throws JSONException {
51
52
ItemMetadata property = ItemMetadata .newProperty (null , "foo" , "java.lang.String" ,
52
53
AdditionalMetadata .class .getName (), null , null , null , null );
53
54
String additionalMetadata = buildAdditionalMetadata (property );
@@ -57,7 +58,7 @@ void mergingOfAdditionalProperty() throws Exception {
57
58
}
58
59
59
60
@ Test
60
- void mergingOfAdditionalPropertyMatchingGroup () throws Exception {
61
+ void mergingOfAdditionalPropertyMatchingGroup () throws JSONException {
61
62
ItemMetadata property = ItemMetadata .newProperty (null , "simple" , "java.lang.String" , null , null , null , null ,
62
63
null );
63
64
String additionalMetadata = buildAdditionalMetadata (property );
@@ -67,7 +68,7 @@ void mergingOfAdditionalPropertyMatchingGroup() throws Exception {
67
68
}
68
69
69
70
@ Test
70
- void mergeExistingPropertyDefaultValue () throws Exception {
71
+ void mergeExistingPropertyDefaultValue () throws JSONException {
71
72
ItemMetadata property = ItemMetadata .newProperty ("simple" , "flag" , null , null , null , null , true , null );
72
73
String additionalMetadata = buildAdditionalMetadata (property );
73
74
ConfigurationMetadata metadata = compile (additionalMetadata , SimpleProperties .class );
@@ -80,7 +81,7 @@ void mergeExistingPropertyDefaultValue() throws Exception {
80
81
}
81
82
82
83
@ Test
83
- void mergeExistingPropertyWithSeveralCandidates () throws Exception {
84
+ void mergeExistingPropertyWithSeveralCandidates () throws JSONException {
84
85
ItemMetadata property = ItemMetadata .newProperty ("simple" , "flag" , Boolean .class .getName (), null , null , null ,
85
86
true , null );
86
87
String additionalMetadata = buildAdditionalMetadata (property );
@@ -111,7 +112,7 @@ void mergeExistingPropertyWithSeveralCandidates() throws Exception {
111
112
}
112
113
113
114
@ Test
114
- void mergeExistingPropertyDescription () throws Exception {
115
+ void mergeExistingPropertyDescription () throws JSONException {
115
116
ItemMetadata property = ItemMetadata .newProperty ("simple" , "comparator" , null , null , null , "A nice comparator." ,
116
117
null , null );
117
118
String additionalMetadata = buildAdditionalMetadata (property );
@@ -123,7 +124,7 @@ void mergeExistingPropertyDescription() throws Exception {
123
124
}
124
125
125
126
@ Test
126
- void mergeExistingPropertyDeprecation () throws Exception {
127
+ void mergeExistingPropertyDeprecation () throws JSONException {
127
128
ItemMetadata property = ItemMetadata .newProperty ("simple" , "comparator" , null , null , null , null , null ,
128
129
new ItemDeprecation ("Don't use this." , "simple.complex-comparator" , "1.2.3" , "error" ));
129
130
String additionalMetadata = buildAdditionalMetadata (property );
@@ -135,7 +136,7 @@ void mergeExistingPropertyDeprecation() throws Exception {
135
136
}
136
137
137
138
@ Test
138
- void mergeExistingPropertyDeprecationOverride () throws Exception {
139
+ void mergeExistingPropertyDeprecationOverride () throws JSONException {
139
140
ItemMetadata property = ItemMetadata .newProperty ("singledeprecated" , "name" , null , null , null , null , null ,
140
141
new ItemDeprecation ("Don't use this." , "single.name" , "1.2.3" ));
141
142
String additionalMetadata = buildAdditionalMetadata (property );
@@ -147,7 +148,7 @@ void mergeExistingPropertyDeprecationOverride() throws Exception {
147
148
}
148
149
149
150
@ Test
150
- void mergeExistingPropertyDeprecationOverrideLevel () throws Exception {
151
+ void mergeExistingPropertyDeprecationOverrideLevel () throws JSONException {
151
152
ItemMetadata property = ItemMetadata .newProperty ("singledeprecated" , "name" , null , null , null , null , null ,
152
153
new ItemDeprecation (null , null , null , "error" ));
153
154
String additionalMetadata = buildAdditionalMetadata (property );
@@ -167,7 +168,7 @@ void mergeOfInvalidAdditionalMetadata() {
167
168
}
168
169
169
170
@ Test
170
- void mergingOfSimpleHint () throws Exception {
171
+ void mergingOfSimpleHint () throws JSONException {
171
172
String hints = buildAdditionalHints (ItemHint .newHint ("simple.the-name" ,
172
173
new ItemHint .ValueHint ("boot" , "Bla bla" ), new ItemHint .ValueHint ("spring" , null )));
173
174
ConfigurationMetadata metadata = compile (hints , SimpleProperties .class );
@@ -181,7 +182,7 @@ void mergingOfSimpleHint() throws Exception {
181
182
}
182
183
183
184
@ Test
184
- void mergingOfHintWithNonCanonicalName () throws Exception {
185
+ void mergingOfHintWithNonCanonicalName () throws JSONException {
185
186
String hints = buildAdditionalHints (
186
187
ItemHint .newHint ("simple.theName" , new ItemHint .ValueHint ("boot" , "Bla bla" )));
187
188
ConfigurationMetadata metadata = compile (hints , SimpleProperties .class );
@@ -194,7 +195,7 @@ void mergingOfHintWithNonCanonicalName() throws Exception {
194
195
}
195
196
196
197
@ Test
197
- void mergingOfHintWithProvider () throws Exception {
198
+ void mergingOfHintWithProvider () throws JSONException {
198
199
String hints = buildAdditionalHints (new ItemHint ("simple.theName" , Collections .emptyList (),
199
200
Arrays .asList (new ItemHint .ValueProvider ("first" , Collections .singletonMap ("target" , "org.foo" )),
200
201
new ItemHint .ValueProvider ("second" , null ))));
@@ -209,7 +210,7 @@ void mergingOfHintWithProvider() throws Exception {
209
210
}
210
211
211
212
@ Test
212
- void mergingOfAdditionalDeprecation () throws Exception {
213
+ void mergingOfAdditionalDeprecation () throws JSONException {
213
214
String deprecations = buildPropertyDeprecations (
214
215
ItemMetadata .newProperty ("simple" , "wrongName" , "java.lang.String" , null , null , null , null ,
215
216
new ItemDeprecation ("Lame name." , "simple.the-name" , "1.2.3" )));
@@ -219,7 +220,7 @@ void mergingOfAdditionalDeprecation() throws Exception {
219
220
}
220
221
221
222
@ Test
222
- void mergingOfAdditionalMetadata () throws Exception {
223
+ void mergingOfAdditionalMetadata () throws JSONException {
223
224
JSONObject property = new JSONObject ();
224
225
property .put ("name" , "foo" );
225
226
property .put ("type" , "java.lang.String" );
@@ -234,7 +235,7 @@ void mergingOfAdditionalMetadata() throws Exception {
234
235
assertThat (metadata ).has (Metadata .withProperty ("foo" , String .class ).fromSource (AdditionalMetadata .class ));
235
236
}
236
237
237
- private String buildAdditionalMetadata (ItemMetadata ... metadata ) throws Exception {
238
+ private String buildAdditionalMetadata (ItemMetadata ... metadata ) throws JSONException {
238
239
TestJsonConverter converter = new TestJsonConverter ();
239
240
JSONObject additionalMetadata = new JSONObject ();
240
241
JSONArray properties = new JSONArray ();
@@ -245,14 +246,14 @@ private String buildAdditionalMetadata(ItemMetadata... metadata) throws Exceptio
245
246
return additionalMetadata .toString ();
246
247
}
247
248
248
- private String buildAdditionalHints (ItemHint ... hints ) throws Exception {
249
+ private String buildAdditionalHints (ItemHint ... hints ) throws JSONException {
249
250
TestJsonConverter converter = new TestJsonConverter ();
250
251
JSONObject additionalMetadata = new JSONObject ();
251
252
additionalMetadata .put ("hints" , converter .toJsonArray (Arrays .asList (hints )));
252
253
return additionalMetadata .toString ();
253
254
}
254
255
255
- private String buildPropertyDeprecations (ItemMetadata ... items ) throws Exception {
256
+ private String buildPropertyDeprecations (ItemMetadata ... items ) throws JSONException {
256
257
JSONArray propertiesArray = new JSONArray ();
257
258
for (ItemMetadata item : items ) {
258
259
JSONObject jsonObject = new JSONObject ();
0 commit comments