16
16
17
17
package com .mongodb .hibernate ;
18
18
19
- import static com .mongodb .hibernate .MongoTestAssertions .assertEquals ;
19
+ import static com .mongodb .hibernate .MongoTestAssertions .assertEq ;
20
20
import static org .assertj .core .api .Assertions .assertThat ;
21
21
22
22
import com .mongodb .client .MongoCollection ;
23
23
import com .mongodb .hibernate .junit .InjectMongoCollection ;
24
24
import com .mongodb .hibernate .junit .MongoExtension ;
25
- import jakarta .persistence .Column ;
26
- import jakarta .persistence .Embeddable ;
27
25
import jakarta .persistence .Entity ;
28
26
import jakarta .persistence .Id ;
29
27
import jakarta .persistence .Table ;
39
37
40
38
@ SessionFactory (exportSchema = false )
41
39
@ DomainModel (
42
- annotatedClasses = {
43
- BasicCrudIntegrationTests .Book .class ,
44
- BasicCrudIntegrationTests .BookWithEmbeddedField .class ,
45
- BasicCrudIntegrationTests .BookDynamicallyUpdated .class
40
+ annotatedClasses = {BasicCrudIntegrationTests .Book .class , BasicCrudIntegrationTests .BookDynamicallyUpdated .class
46
41
})
47
42
@ ExtendWith (MongoExtension .class )
48
43
class BasicCrudIntegrationTests implements SessionFactoryScopeAware {
@@ -106,31 +101,6 @@ void testEntityWithNullFieldValueInsertion() {
106
101
.formatted (author ));
107
102
assertCollectionContainsExactly (expectedDocument );
108
103
}
109
-
110
- @ Test
111
- void testEntityWithEmbeddedFieldInsertion () {
112
- sessionFactoryScope .inTransaction (session -> {
113
- var book = new BookWithEmbeddedField ();
114
- book .id = 1 ;
115
- book .title = "War and Peace" ;
116
- var author = new Author ();
117
- author .firstName = "Leo" ;
118
- author .lastName = "Tolstoy" ;
119
- book .author = author ;
120
- book .publishYear = 1867 ;
121
- session .persist (book );
122
- });
123
- var expectedDocument = BsonDocument .parse (
124
- """
125
- {
126
- _id: 1,
127
- title: "War and Peace",
128
- authorFirstName: "Leo",
129
- authorLastName: "Tolstoy",
130
- publishYear: 1867
131
- }""" );
132
- assertCollectionContainsExactly (expectedDocument );
133
- }
134
104
}
135
105
136
106
@ Nested
@@ -219,7 +189,7 @@ void testFindByPrimaryKeyWithoutNullValueField() {
219
189
220
190
sessionFactoryScope .inTransaction (session -> session .persist (book ));
221
191
var loadedBook = sessionFactoryScope .fromTransaction (session -> session .find (Book .class , 1 ));
222
- assertEquals (book , loadedBook );
192
+ assertEq (book , loadedBook );
223
193
}
224
194
225
195
@ Test
@@ -236,7 +206,7 @@ void testFindByPrimaryKeyWithNullValueField() {
236
206
237
207
sessionFactoryScope .inTransaction (session -> session .persist (book ));
238
208
var loadedBook = sessionFactoryScope .fromTransaction (session -> session .find (Book .class , 1 ));
239
- assertEquals (book , loadedBook );
209
+ assertEq (book , loadedBook );
240
210
}
241
211
}
242
212
@@ -270,27 +240,4 @@ static class BookDynamicallyUpdated {
270
240
271
241
int publishYear ;
272
242
}
273
-
274
- @ Entity
275
- @ Table (name = "books" )
276
- static class BookWithEmbeddedField {
277
- @ Id
278
- int id ;
279
-
280
- String title ;
281
-
282
- Author author ;
283
-
284
- int publishYear ;
285
- }
286
-
287
- @ Embeddable
288
- static class Author {
289
-
290
- @ Column (name = "authorFirstName" )
291
- String firstName ;
292
-
293
- @ Column (name = "authorLastName" )
294
- String lastName ;
295
- }
296
243
}
0 commit comments