32
32
33
33
import org .bson .Document ;
34
34
import org .junit .jupiter .api .Test ;
35
-
36
35
import org .springframework .data .domain .Range ;
37
36
import org .springframework .data .domain .Range .*;
38
37
43
42
* @author Mark Paluch
44
43
* @author Michał Kurcius
45
44
*/
46
- public class JsonSchemaObjectUnitTests {
45
+ class JsonSchemaObjectUnitTests {
47
46
48
47
// -----------------
49
48
// type from class
50
49
// -----------------
51
50
52
51
@ Test // DATAMONGO-1849
53
- public void primitiveType () {
52
+ void primitiveType () {
54
53
55
54
assertThat (JsonSchemaObject .of (boolean .class ).getTypes ()).containsExactly (Type .booleanType ());
56
55
assertThat (JsonSchemaObject .of (int .class ).getTypes ()).containsExactly (Type .intType ());
@@ -61,20 +60,20 @@ public void primitiveType() {
61
60
}
62
61
63
62
@ Test // DATAMONGO-1849
64
- public void objectType () {
63
+ void objectType () {
65
64
66
65
assertThat (JsonSchemaObject .of (Object .class ).getTypes ()).containsExactly (Type .objectType ());
67
66
assertThat (JsonSchemaObject .of (Map .class ).getTypes ()).containsExactly (Type .objectType ());
68
67
assertThat (JsonSchemaObject .of (Document .class ).getTypes ()).containsExactly (Type .objectType ());
69
68
}
70
69
71
70
@ Test // DATAMONGO-1849
72
- public void binaryData () {
71
+ void binaryData () {
73
72
assertThat (JsonSchemaObject .of (byte [].class ).getTypes ()).containsExactly (Type .binaryType ());
74
73
}
75
74
76
75
@ Test // DATAMONGO-1849
77
- public void collectionType () {
76
+ void collectionType () {
78
77
79
78
assertThat (JsonSchemaObject .of (Object [].class ).getTypes ()).containsExactly (Type .arrayType ());
80
79
assertThat (JsonSchemaObject .of (Collection .class ).getTypes ()).containsExactly (Type .arrayType ());
@@ -83,7 +82,7 @@ public void collectionType() {
83
82
}
84
83
85
84
@ Test // DATAMONGO-1849
86
- public void dateType () {
85
+ void dateType () {
87
86
assertThat (JsonSchemaObject .of (Date .class ).getTypes ()).containsExactly (Type .dateType ());
88
87
}
89
88
@@ -92,22 +91,22 @@ public void dateType() {
92
91
// -----------------
93
92
94
93
@ Test // DATAMONGO-1835
95
- public void objectObjectShouldRenderTypeCorrectly () {
94
+ void objectObjectShouldRenderTypeCorrectly () {
96
95
97
96
assertThat (object ().generatedDescription ().toDocument ())
98
97
.isEqualTo (new Document ("type" , "object" ).append ("description" , "Must be an object." ));
99
98
}
100
99
101
100
@ Test // DATAMONGO-1835
102
- public void objectObjectShouldRenderNrPropertiesCorrectly () {
101
+ void objectObjectShouldRenderNrPropertiesCorrectly () {
103
102
104
103
assertThat (object ().propertiesCount (from (inclusive (10 )).to (inclusive (20 ))).generatedDescription ().toDocument ())
105
104
.isEqualTo (new Document ("type" , "object" ).append ("description" , "Must be an object with [10-20] properties." )
106
105
.append ("minProperties" , 10 ).append ("maxProperties" , 20 ));
107
106
}
108
107
109
108
@ Test // DATAMONGO-1835
110
- public void objectObjectShouldRenderRequiredPropertiesCorrectly () {
109
+ void objectObjectShouldRenderRequiredPropertiesCorrectly () {
111
110
112
111
assertThat (object ().required ("spring" , "data" , "mongodb" ).generatedDescription ().toDocument ())
113
112
.isEqualTo (new Document ("type" , "object" )
@@ -116,7 +115,7 @@ public void objectObjectShouldRenderRequiredPropertiesCorrectly() {
116
115
}
117
116
118
117
@ Test // DATAMONGO-1835
119
- public void objectObjectShouldRenderAdditionalPropertiesCorrectlyWhenBoolean () {
118
+ void objectObjectShouldRenderAdditionalPropertiesCorrectlyWhenBoolean () {
120
119
121
120
assertThat (object ().additionalProperties (true ).generatedDescription ().toDocument ()).isEqualTo (
122
121
new Document ("type" , "object" ).append ("description" , "Must be an object allowing additional properties." )
@@ -128,7 +127,7 @@ public void objectObjectShouldRenderAdditionalPropertiesCorrectlyWhenBoolean() {
128
127
}
129
128
130
129
@ Test // DATAMONGO-1835
131
- public void objectObjectShouldRenderPropertiesCorrectly () {
130
+ void objectObjectShouldRenderPropertiesCorrectly () {
132
131
133
132
Document expected = new Document ("type" , "object" )
134
133
.append ("description" , "Must be an object defining restrictions for name, active." ).append ("properties" ,
@@ -143,7 +142,7 @@ public void objectObjectShouldRenderPropertiesCorrectly() {
143
142
}
144
143
145
144
@ Test // DATAMONGO-1835
146
- public void objectObjectShouldRenderNestedObjectPropertiesCorrectly () {
145
+ void objectObjectShouldRenderNestedObjectPropertiesCorrectly () {
147
146
148
147
Document expected = new Document ("type" , "object" )
149
148
.append ("description" , "Must be an object defining restrictions for address." )
@@ -159,7 +158,7 @@ public void objectObjectShouldRenderNestedObjectPropertiesCorrectly() {
159
158
}
160
159
161
160
@ Test // DATAMONGO-1835
162
- public void objectObjectShouldRenderPatternPropertiesCorrectly () {
161
+ void objectObjectShouldRenderPatternPropertiesCorrectly () {
163
162
164
163
Document expected = new Document ("type" , "object" )
165
164
.append ("description" , "Must be an object defining restrictions for patterns na.*." )
@@ -171,7 +170,7 @@ public void objectObjectShouldRenderPatternPropertiesCorrectly() {
171
170
}
172
171
173
172
@ Test // DATAMONGO-1849
174
- public void objectShouldIncludeRequiredNestedCorrectly () {
173
+ void objectShouldIncludeRequiredNestedCorrectly () {
175
174
176
175
assertThat (object () //
177
176
.properties ( //
@@ -186,29 +185,29 @@ public void objectShouldIncludeRequiredNestedCorrectly() {
186
185
// -----------------
187
186
188
187
@ Test // DATAMONGO-1835
189
- public void stringObjectShouldRenderTypeCorrectly () {
188
+ void stringObjectShouldRenderTypeCorrectly () {
190
189
191
190
assertThat (string ().generatedDescription ().toDocument ())
192
191
.isEqualTo (new Document ("type" , "string" ).append ("description" , "Must be a string." ));
193
192
}
194
193
195
194
@ Test // DATAMONGO-1835
196
- public void stringObjectShouldRenderDescriptionCorrectly () {
195
+ void stringObjectShouldRenderDescriptionCorrectly () {
197
196
198
197
assertThat (string ().description ("error msg" ).toDocument ())
199
198
.isEqualTo (new Document ("type" , "string" ).append ("description" , "error msg" ));
200
199
}
201
200
202
201
@ Test // DATAMONGO-1835
203
- public void stringObjectShouldRenderRangeCorrectly () {
202
+ void stringObjectShouldRenderRangeCorrectly () {
204
203
205
204
assertThat (string ().length (from (inclusive (10 )).to (inclusive (20 ))).generatedDescription ().toDocument ())
206
205
.isEqualTo (new Document ("type" , "string" ).append ("description" , "Must be a string with length [10-20]." )
207
206
.append ("minLength" , 10 ).append ("maxLength" , 20 ));
208
207
}
209
208
210
209
@ Test // DATAMONGO-1835
211
- public void stringObjectShouldRenderPatternCorrectly () {
210
+ void stringObjectShouldRenderPatternCorrectly () {
212
211
213
212
assertThat (string ().matching ("^spring$" ).generatedDescription ().toDocument ())
214
213
.isEqualTo (new Document ("type" , "string" ).append ("description" , "Must be a string matching ^spring$." )
@@ -220,15 +219,15 @@ public void stringObjectShouldRenderPatternCorrectly() {
220
219
// -----------------
221
220
222
221
@ Test // DATAMONGO-1835
223
- public void numberObjectShouldRenderMultipleOfCorrectly () {
222
+ void numberObjectShouldRenderMultipleOfCorrectly () {
224
223
225
224
assertThat (number ().multipleOf (3.141592F ).generatedDescription ().toDocument ())
226
225
.isEqualTo (new Document ("type" , "number" ).append ("description" , "Must be a numeric value multiple of 3.141592." )
227
226
.append ("multipleOf" , 3.141592F ));
228
227
}
229
228
230
229
@ Test // DATAMONGO-1835
231
- public void numberObjectShouldRenderMaximumCorrectly () {
230
+ void numberObjectShouldRenderMaximumCorrectly () {
232
231
233
232
assertThat (
234
233
number ().within (Range .of (Bound .unbounded (), Bound .inclusive (3.141592F ))).generatedDescription ().toDocument ())
@@ -244,7 +243,7 @@ public void numberObjectShouldRenderMaximumCorrectly() {
244
243
}
245
244
246
245
@ Test // DATAMONGO-1835
247
- public void numberObjectShouldRenderMinimumCorrectly () {
246
+ void numberObjectShouldRenderMinimumCorrectly () {
248
247
249
248
assertThat (
250
249
number ().within (Range .of (Bound .inclusive (3.141592F ), Bound .unbounded ())).generatedDescription ().toDocument ())
@@ -264,42 +263,42 @@ public void numberObjectShouldRenderMinimumCorrectly() {
264
263
// -----------------
265
264
266
265
@ Test // DATAMONGO-1835
267
- public void arrayObjectShouldRenderItemsCorrectly () {
266
+ void arrayObjectShouldRenderItemsCorrectly () {
268
267
269
268
assertThat (array ().items (Arrays .asList (string (), bool ())).toDocument ()).isEqualTo (new Document ("type" , "array" )
270
269
.append ("items" , Arrays .asList (new Document ("type" , "string" ), new Document ("type" , "boolean" ))));
271
270
}
272
271
273
272
@ Test // DATAMONGO-2613
274
- public void arrayObjectShouldRenderItemsCorrectlyAsObjectIfContainsOnlyOneElement () {
273
+ void arrayObjectShouldRenderItemsCorrectlyAsObjectIfContainsOnlyOneElement () {
275
274
276
- assertThat (array ().items (Collections .singletonList (string ())).toDocument ()). isEqualTo ( new Document ( "type" , "array" )
277
- .append ("items" , new Document ("type" , "string" )));
275
+ assertThat (array ().items (Collections .singletonList (string ())).toDocument ())
276
+ .isEqualTo ( new Document ( "type" , "array" ). append ("items" , new Document ("type" , "string" )));
278
277
}
279
278
280
279
@ Test // DATAMONGO-1835
281
- public void arrayObjectShouldRenderMaxItemsCorrectly () {
280
+ void arrayObjectShouldRenderMaxItemsCorrectly () {
282
281
283
282
assertThat (array ().maxItems (5 ).generatedDescription ().toDocument ()).isEqualTo (new Document ("type" , "array" )
284
283
.append ("description" , "Must be an array having size unbounded-5]." ).append ("maxItems" , 5 ));
285
284
}
286
285
287
286
@ Test // DATAMONGO-1835
288
- public void arrayObjectShouldRenderMinItemsCorrectly () {
287
+ void arrayObjectShouldRenderMinItemsCorrectly () {
289
288
290
289
assertThat (array ().minItems (5 ).generatedDescription ().toDocument ()).isEqualTo (new Document ("type" , "array" )
291
290
.append ("description" , "Must be an array having size [5-unbounded." ).append ("minItems" , 5 ));
292
291
}
293
292
294
293
@ Test // DATAMONGO-1835
295
- public void arrayObjectShouldRenderUniqueItemsCorrectly () {
294
+ void arrayObjectShouldRenderUniqueItemsCorrectly () {
296
295
297
296
assertThat (array ().uniqueItems (true ).generatedDescription ().toDocument ()).isEqualTo (new Document ("type" , "array" )
298
297
.append ("description" , "Must be an array of unique values." ).append ("uniqueItems" , true ));
299
298
}
300
299
301
300
@ Test // DATAMONGO-1835
302
- public void arrayObjectShouldRenderAdditionalItemsItemsCorrectly () {
301
+ void arrayObjectShouldRenderAdditionalItemsItemsCorrectly () {
303
302
304
303
assertThat (array ().additionalItems (true ).generatedDescription ().toDocument ())
305
304
.isEqualTo (new Document ("type" , "array" ).append ("description" , "Must be an array with additional items." )
@@ -314,7 +313,7 @@ public void arrayObjectShouldRenderAdditionalItemsItemsCorrectly() {
314
313
// -----------------
315
314
316
315
@ Test // DATAMONGO-1835
317
- public void booleanShouldRenderCorrectly () {
316
+ void booleanShouldRenderCorrectly () {
318
317
319
318
assertThat (bool ().generatedDescription ().toDocument ())
320
319
.isEqualTo (new Document ("type" , "boolean" ).append ("description" , "Must be a boolean." ));
@@ -325,7 +324,7 @@ public void booleanShouldRenderCorrectly() {
325
324
// -----------------
326
325
327
326
@ Test // DATAMONGO-1835
328
- public void nullShouldRenderCorrectly () {
327
+ void nullShouldRenderCorrectly () {
329
328
330
329
assertThat (nil ().generatedDescription ().toDocument ())
331
330
.isEqualTo (new Document ("type" , "null" ).append ("description" , "Must be null." ));
@@ -336,7 +335,7 @@ public void nullShouldRenderCorrectly() {
336
335
// -----------------
337
336
338
337
@ Test // DATAMONGO-1877
339
- public void dateShouldRenderCorrectly () {
338
+ void dateShouldRenderCorrectly () {
340
339
341
340
assertThat (date ().generatedDescription ().toDocument ())
342
341
.isEqualTo (new Document ("bsonType" , "date" ).append ("description" , "Must be a date." ));
@@ -347,7 +346,7 @@ public void dateShouldRenderCorrectly() {
347
346
// -----------------
348
347
349
348
@ Test // DATAMONGO-1877
350
- public void timestampShouldRenderCorrectly () {
349
+ void timestampShouldRenderCorrectly () {
351
350
352
351
assertThat (timestamp ().generatedDescription ().toDocument ())
353
352
.isEqualTo (new Document ("bsonType" , "timestamp" ).append ("description" , "Must be a timestamp." ));
@@ -358,35 +357,35 @@ public void timestampShouldRenderCorrectly() {
358
357
// -----------------
359
358
360
359
@ Test // DATAMONGO-1835
361
- public void typedObjectShouldRenderEnumCorrectly () {
360
+ void typedObjectShouldRenderEnumCorrectly () {
362
361
363
362
assertThat (of (String .class ).possibleValues (Arrays .asList ("one" , "two" )).toDocument ())
364
363
.isEqualTo (new Document ("type" , "string" ).append ("enum" , Arrays .asList ("one" , "two" )));
365
364
}
366
365
367
366
@ Test // DATAMONGO-1835
368
- public void typedObjectShouldRenderAllOfCorrectly () {
367
+ void typedObjectShouldRenderAllOfCorrectly () {
369
368
370
369
assertThat (of (Object .class ).allOf (Arrays .asList (string ())).toDocument ())
371
370
.isEqualTo (new Document ("type" , "object" ).append ("allOf" , Arrays .asList (new Document ("type" , "string" ))));
372
371
}
373
372
374
373
@ Test // DATAMONGO-1835
375
- public void typedObjectShouldRenderAnyOfCorrectly () {
374
+ void typedObjectShouldRenderAnyOfCorrectly () {
376
375
377
376
assertThat (of (String .class ).anyOf (Arrays .asList (string ())).toDocument ())
378
377
.isEqualTo (new Document ("type" , "string" ).append ("anyOf" , Arrays .asList (new Document ("type" , "string" ))));
379
378
}
380
379
381
380
@ Test // DATAMONGO-1835
382
- public void typedObjectShouldRenderOneOfCorrectly () {
381
+ void typedObjectShouldRenderOneOfCorrectly () {
383
382
384
383
assertThat (of (String .class ).oneOf (Arrays .asList (string ())).toDocument ())
385
384
.isEqualTo (new Document ("type" , "string" ).append ("oneOf" , Arrays .asList (new Document ("type" , "string" ))));
386
385
}
387
386
388
387
@ Test // DATAMONGO-1835
389
- public void typedObjectShouldRenderNotCorrectly () {
388
+ void typedObjectShouldRenderNotCorrectly () {
390
389
391
390
assertThat (untyped ().notMatch (string ()).toDocument ())
392
391
.isEqualTo (new Document ("not" , new Document ("type" , "string" )));
0 commit comments