59
59
class MappingJdbcConverterUnitTests {
60
60
61
61
private static final UUID UUID = java .util .UUID .fromString ("87a48aa8-a071-705e-54a9-e52fe3a012f1" );
62
- private static final byte [] BYTES_REPRESENTING_UUID = { -121 , -92 , -118 , -88 , -96 , 113 , 112 , 94 , 84 , -87 , -27 , 47 ,
62
+ private static final byte [] BYTES_REPRESENTING_UUID = {-121 , -92 , -118 , -88 , -96 , 113 , 112 , 94 , 84 , -87 , -27 , 47 ,
63
63
-29 ,
64
- -96 , 18 , -15 };
64
+ -96 , 18 , -15 };
65
65
66
66
private JdbcMappingContext context = new JdbcMappingContext ();
67
67
private StubbedJdbcTypeFactory typeFactory = new StubbedJdbcTypeFactory ();
@@ -74,28 +74,29 @@ class MappingJdbcConverterUnitTests {
74
74
typeFactory //
75
75
);
76
76
77
- @ Test // DATAJDBC-104, DATAJDBC-1384
77
+ @ Test
78
+ // DATAJDBC-104, DATAJDBC-1384
78
79
void testTargetTypesForPropertyType () {
79
80
80
81
RelationalPersistentEntity <?> entity = context .getRequiredPersistentEntity (DummyEntity .class );
81
82
82
- SoftAssertions softly = new SoftAssertions ();
83
-
84
- checkTargetType (softly , entity , "someEnum" , String .class );
85
- checkTargetType (softly , entity , "localDateTime" , LocalDateTime .class );
86
- checkTargetType (softly , entity , "localDate" , Timestamp .class );
87
- checkTargetType (softly , entity , "localTime" , Timestamp .class );
88
- checkTargetType (softly , entity , "zonedDateTime" , String .class );
89
- checkTargetType (softly , entity , "offsetDateTime" , OffsetDateTime .class );
90
- checkTargetType (softly , entity , "instant" , Timestamp .class );
91
- checkTargetType (softly , entity , "date" , Date .class );
92
- checkTargetType (softly , entity , "timestamp" , Timestamp .class );
93
- checkTargetType (softly , entity , "uuid" , UUID .class );
94
-
95
- softly .assertAll ();
83
+ SoftAssertions .assertSoftly (softly -> {
84
+
85
+ checkTargetType (softly , entity , "someEnum" , String .class );
86
+ checkTargetType (softly , entity , "localDateTime" , LocalDateTime .class );
87
+ checkTargetType (softly , entity , "localDate" , Timestamp .class );
88
+ checkTargetType (softly , entity , "localTime" , Timestamp .class );
89
+ checkTargetType (softly , entity , "zonedDateTime" , String .class );
90
+ checkTargetType (softly , entity , "offsetDateTime" , OffsetDateTime .class );
91
+ checkTargetType (softly , entity , "instant" , Timestamp .class );
92
+ checkTargetType (softly , entity , "date" , Date .class );
93
+ checkTargetType (softly , entity , "timestamp" , Timestamp .class );
94
+ checkTargetType (softly , entity , "uuid" , UUID .class );
95
+ });
96
96
}
97
97
98
- @ Test // DATAJDBC-259
98
+ @ Test
99
+ // DATAJDBC-259
99
100
void classificationOfCollectionLikeProperties () {
100
101
101
102
RelationalPersistentEntity <?> entity = context .getRequiredPersistentEntity (DummyEntity .class );
@@ -111,22 +112,24 @@ void classificationOfCollectionLikeProperties() {
111
112
softly .assertAll ();
112
113
}
113
114
114
- @ Test // DATAJDBC-221
115
+ @ Test
116
+ // DATAJDBC-221
115
117
void referencesAreNotEntitiesAndGetStoredAsTheirId () {
116
118
117
119
RelationalPersistentEntity <?> entity = context .getRequiredPersistentEntity (DummyEntity .class );
118
120
119
- SoftAssertions softly = new SoftAssertions ();
120
121
121
122
RelationalPersistentProperty reference = entity .getRequiredPersistentProperty ("reference" );
122
123
123
- softly .assertThat (reference .isEntity ()).isFalse ();
124
- softly .assertThat (converter .getColumnType (reference )).isEqualTo (Long .class );
124
+ SoftAssertions .assertSoftly (softly -> {
125
125
126
- softly .assertAll ();
126
+ softly .assertThat (reference .isEntity ()).isFalse ();
127
+ softly .assertThat (converter .getColumnType (reference )).isEqualTo (Long .class );
128
+ });
127
129
}
128
130
129
- @ Test // DATAJDBC-637
131
+ @ Test
132
+ // DATAJDBC-637
130
133
void conversionOfDateLikeValueAndBackYieldsOriginalValue () {
131
134
132
135
RelationalPersistentEntity <?> persistentEntity = context .getRequiredPersistentEntity (DummyEntity .class );
@@ -142,17 +145,19 @@ void conversionOfDateLikeValueAndBackYieldsOriginalValue() {
142
145
143
146
}
144
147
145
- @ Test // GH-945
148
+ @ Test
149
+ // GH-945
146
150
void conversionOfPrimitiveArrays () {
147
151
148
- int [] ints = { 1 , 2 , 3 , 4 , 5 };
152
+ int [] ints = {1 , 2 , 3 , 4 , 5 };
149
153
JdbcValue converted = converter .writeJdbcValue (ints , ints .getClass (), JdbcUtil .targetSqlTypeFor (ints .getClass ()));
150
154
151
155
assertThat (converted .getValue ()).isInstanceOf (Array .class );
152
156
assertThat (typeFactory .arraySource ).containsExactly (1 , 2 , 3 , 4 , 5 );
153
157
}
154
158
155
- @ Test // GH-1684
159
+ @ Test
160
+ // GH-1684
156
161
void accessesCorrectValuesForOneToOneRelationshipWithIdenticallyNamedIdProperties () {
157
162
158
163
RowDocument rowdocument = new RowDocument (Map .of ("ID" , "one" , "REFERENCED_ID" , 23 ));
@@ -162,7 +167,8 @@ void accessesCorrectValuesForOneToOneRelationshipWithIdenticallyNamedIdPropertie
162
167
assertThat (result ).isEqualTo (new WithOneToOne ("one" , new Referenced (23L )));
163
168
}
164
169
165
- @ Test // GH-1750
170
+ @ Test
171
+ // GH-1750
166
172
void readByteArrayToNestedUuidWithCustomConverter () {
167
173
168
174
JdbcMappingContext context = new JdbcMappingContext ();
@@ -186,7 +192,7 @@ void readByteArrayToNestedUuidWithCustomConverter() {
186
192
}
187
193
188
194
private static void checkReadConversion (SoftAssertions softly , MappingJdbcConverter converter , String propertyName ,
189
- Object expected ) {
195
+ Object expected ) {
190
196
191
197
RelationalPersistentProperty property = converter .getMappingContext ().getRequiredPersistentEntity (DummyEntity .class )
192
198
.getRequiredPersistentProperty (propertyName );
@@ -197,7 +203,7 @@ private static void checkReadConversion(SoftAssertions softly, MappingJdbcConver
197
203
}
198
204
199
205
private void checkConversionToTimestampAndBack (SoftAssertions softly , RelationalPersistentEntity <?> persistentEntity ,
200
- String propertyName , Object value ) {
206
+ String propertyName , Object value ) {
201
207
202
208
RelationalPersistentProperty property = persistentEntity .getRequiredPersistentProperty (propertyName );
203
209
@@ -208,125 +214,36 @@ private void checkConversionToTimestampAndBack(SoftAssertions softly, Relational
208
214
}
209
215
210
216
private void checkTargetType (SoftAssertions softly , RelationalPersistentEntity <?> persistentEntity ,
211
- String propertyName , Class <?> expected ) {
217
+ String propertyName , Class <?> expected ) {
212
218
213
219
RelationalPersistentProperty property = persistentEntity .getRequiredPersistentProperty (propertyName );
214
220
215
221
softly .assertThat (converter .getColumnType (property )).describedAs (propertyName ).isEqualTo (expected );
216
222
}
217
223
218
224
@ SuppressWarnings ("unused" )
219
- private static class DummyEntity {
220
-
221
- @ Id private final Long id ;
222
- private final SomeEnum someEnum ;
223
- private final LocalDateTime localDateTime ;
224
- private final LocalDate localDate ;
225
- private final LocalTime localTime ;
226
- private final ZonedDateTime zonedDateTime ;
227
- private final OffsetDateTime offsetDateTime ;
228
- private final Instant instant ;
229
- private final Date date ;
230
- private final Timestamp timestamp ;
231
- private final AggregateReference <DummyEntity , Long > reference ;
232
- private final UUID uuid ;
233
- private final AggregateReference <ReferencedByUuid , UUID > uuidRef ;
234
- private final Optional <UUID > optionalUuid ;
235
-
236
- // DATAJDBC-259
237
- private final List <String > listOfString ;
238
- private final String [] arrayOfString ;
239
- private final List <OtherEntity > listOfEntity ;
240
- private final OtherEntity [] arrayOfEntity ;
241
-
242
- private DummyEntity (Long id , SomeEnum someEnum , LocalDateTime localDateTime , LocalDate localDate ,
243
- LocalTime localTime , ZonedDateTime zonedDateTime , OffsetDateTime offsetDateTime , Instant instant , Date date ,
244
- Timestamp timestamp , AggregateReference <DummyEntity , Long > reference , UUID uuid ,
245
- AggregateReference <ReferencedByUuid , UUID > uuidRef , Optional <java .util .UUID > optionalUUID , List <String > listOfString , String [] arrayOfString ,
246
- List <OtherEntity > listOfEntity , OtherEntity [] arrayOfEntity ) {
247
- this .id = id ;
248
- this .someEnum = someEnum ;
249
- this .localDateTime = localDateTime ;
250
- this .localDate = localDate ;
251
- this .localTime = localTime ;
252
- this .zonedDateTime = zonedDateTime ;
253
- this .offsetDateTime = offsetDateTime ;
254
- this .instant = instant ;
255
- this .date = date ;
256
- this .timestamp = timestamp ;
257
- this .reference = reference ;
258
- this .uuid = uuid ;
259
- this .uuidRef = uuidRef ;
260
- this .optionalUuid = optionalUUID ;
261
- this .listOfString = listOfString ;
262
- this .arrayOfString = arrayOfString ;
263
- this .listOfEntity = listOfEntity ;
264
- this .arrayOfEntity = arrayOfEntity ;
265
- }
266
-
267
- public Long getId () {
268
- return this .id ;
269
- }
270
-
271
- public SomeEnum getSomeEnum () {
272
- return this .someEnum ;
273
- }
274
-
275
- public LocalDateTime getLocalDateTime () {
276
- return this .localDateTime ;
277
- }
278
-
279
- public LocalDate getLocalDate () {
280
- return this .localDate ;
281
- }
282
-
283
- public LocalTime getLocalTime () {
284
- return this .localTime ;
285
- }
286
-
287
- public ZonedDateTime getZonedDateTime () {
288
- return this .zonedDateTime ;
289
- }
290
-
291
- public OffsetDateTime getOffsetDateTime () {
292
- return this .offsetDateTime ;
293
- }
294
-
295
- public Instant getInstant () {
296
- return this .instant ;
297
- }
298
-
299
- public Date getDate () {
300
- return this .date ;
301
- }
302
-
303
- public Timestamp getTimestamp () {
304
- return this .timestamp ;
305
- }
306
-
307
- public AggregateReference <DummyEntity , Long > getReference () {
308
- return this .reference ;
309
- }
310
-
311
- public UUID getUuid () {
312
- return this .uuid ;
313
- }
314
-
315
- public List <String > getListOfString () {
316
- return this .listOfString ;
317
- }
318
-
319
- public String [] getArrayOfString () {
320
- return this .arrayOfString ;
321
- }
322
-
323
- public List <OtherEntity > getListOfEntity () {
324
- return this .listOfEntity ;
325
- }
326
-
327
- public OtherEntity [] getArrayOfEntity () {
328
- return this .arrayOfEntity ;
329
- }
225
+ private record DummyEntity (
226
+ @ Id Long id ,
227
+ SomeEnum someEnum ,
228
+ LocalDateTime localDateTime ,
229
+ LocalDate localDate ,
230
+ LocalTime localTime ,
231
+ ZonedDateTime zonedDateTime ,
232
+ OffsetDateTime offsetDateTime ,
233
+ Instant instant ,
234
+ Date date ,
235
+ Timestamp timestamp ,
236
+ AggregateReference <DummyEntity , Long > reference ,
237
+ UUID uuid ,
238
+ AggregateReference <ReferencedByUuid , UUID > uuidRef ,
239
+ Optional <UUID > optionalUuid ,
240
+
241
+ // DATAJDBC-259
242
+ List <String > listOfString ,
243
+ String [] arrayOfString ,
244
+ List <OtherEntity > listOfEntity ,
245
+ OtherEntity [] arrayOfEntity
246
+ ) {
330
247
}
331
248
332
249
@ SuppressWarnings ("unused" )
@@ -335,7 +252,8 @@ private enum SomeEnum {
335
252
}
336
253
337
254
@ SuppressWarnings ("unused" )
338
- private static class OtherEntity {}
255
+ private static class OtherEntity {
256
+ }
339
257
340
258
private static class StubbedJdbcTypeFactory implements JdbcTypeFactory {
341
259
Object [] arraySource ;
0 commit comments