1717package com .mongodb .hibernate ;
1818
1919import static com .mongodb .hibernate .MongoTestAssertions .assertEq ;
20+ import static java .util .Arrays .asList ;
2021import static org .assertj .core .api .Assertions .assertThat ;
2122import static org .assertj .core .api .Assertions .assertThatThrownBy ;
2223import static org .hibernate .cfg .AvailableSettings .WRAPPER_ARRAY_HANDLING ;
4748import org .hibernate .testing .orm .junit .SessionFactoryScope ;
4849import org .hibernate .testing .orm .junit .SessionFactoryScopeAware ;
4950import org .hibernate .testing .orm .junit .Setting ;
50- import org .junit .jupiter .api .Disabled ;
5151import org .junit .jupiter .api .Nested ;
5252import org .junit .jupiter .api .Test ;
5353import org .junit .jupiter .api .extension .ExtendWith ;
@@ -78,33 +78,32 @@ public void injectSessionFactoryScope(SessionFactoryScope sessionFactoryScope) {
7878 void testArrayAndCollectionValues () {
7979 var item = new ItemWithArrayAndCollectionValues (
8080 1 ,
81- // TODO-HIBERNATE-48 sprinkle on `null` array/collection elements
8281 new byte [] {2 , 3 },
8382 new char [] {'s' , 't' , 'r' },
8483 new int [] {5 },
8584 new long [] {Long .MAX_VALUE , 6 },
8685 new double [] {Double .MAX_VALUE },
8786 new boolean [] {true },
88- new Character [] {'s' , 't' , 'r' },
89- new Integer [] {7 },
90- new Long [] {8L },
91- new Double [] {9.1d },
92- new Boolean [] {true },
93- new String [] {"str" },
94- new BigDecimal [] {BigDecimal .valueOf (10.1 )},
95- new ObjectId [] {new ObjectId ("000000000000000000000001" )},
87+ new Character [] {'s' , null , 't' , 'r' },
88+ new Integer [] {null , 7 },
89+ new Long [] {8L , null },
90+ new Double [] {9.1d , null },
91+ new Boolean [] {true , null },
92+ new String [] {null , "str" },
93+ new BigDecimal [] {null , BigDecimal .valueOf (10.1 )},
94+ new ObjectId [] {new ObjectId ("000000000000000000000001" ), null },
9695 new StructAggregateEmbeddableIntegrationTests .Single [] {
97- new StructAggregateEmbeddableIntegrationTests .Single (1 )
96+ new StructAggregateEmbeddableIntegrationTests .Single (1 ), null
9897 },
99- List . of ('s' , 't' , 'r' ),
100- List . of ( 5 ),
101- List . of (Long .MAX_VALUE , 6L ),
102- List . of ( Double .MAX_VALUE ),
103- List . of ( true ),
104- List . of ("str" ),
105- List . of (BigDecimal .valueOf (10.1 )),
106- List . of ( new ObjectId ("000000000000000000000001" )),
107- List . of (new StructAggregateEmbeddableIntegrationTests .Single (1 )));
98+ asList ('s' , 't' , null , 'r' ),
99+ asList ( null , 5 ),
100+ asList (Long .MAX_VALUE , null , 6L ),
101+ asList ( null , Double .MAX_VALUE ),
102+ asList ( null , true ),
103+ asList ("str" , null ),
104+ asList (BigDecimal .valueOf (10.1 ), null ),
105+ asList ( null , new ObjectId ("000000000000000000000001" )),
106+ asList (new StructAggregateEmbeddableIntegrationTests .Single (1 ), null ));
108107 sessionFactoryScope .inTransaction (session -> session .persist (item ));
109108 assertCollectionContainsExactly (
110109 """
@@ -116,24 +115,24 @@ void testArrayAndCollectionValues() {
116115 longs: [{$numberLong: "9223372036854775807"}, {$numberLong: "6"}],
117116 doubles: [{$numberDouble: "1.7976931348623157E308"}],
118117 booleans: [true],
119- boxedChars: ["s", "t", "r"],
120- boxedInts: [7],
121- boxedLongs: [{$numberLong: "8"}],
122- boxedDoubles: [{$numberDouble: "9.1"}],
123- boxedBooleans: [true],
124- strings: ["str"],
125- bigDecimals: [{$numberDecimal: "10.1"}],
126- objectIds: [{$oid: "000000000000000000000001"}],
127- structAggregateEmbeddables: [{a: 1}],
128- charsCollection: ["s", "t", "r"],
129- intsCollection: [5],
130- longsCollection: [{$numberLong: "9223372036854775807"}, {$numberLong: "6"}],
131- doublesCollection: [{$numberDouble: "1.7976931348623157E308"}],
132- booleansCollection: [true],
133- stringsCollection: ["str"],
134- bigDecimalsCollection: [{$numberDecimal: "10.1"}],
135- objectIdsCollection: [{$oid: "000000000000000000000001"}],
136- structAggregateEmbeddablesCollection: [{a: 1}]
118+ boxedChars: ["s", null, "t", "r"],
119+ boxedInts: [null, 7],
120+ boxedLongs: [{$numberLong: "8"}, null ],
121+ boxedDoubles: [{$numberDouble: "9.1"}, null ],
122+ boxedBooleans: [true, null ],
123+ strings: [null, "str"],
124+ bigDecimals: [null, {$numberDecimal: "10.1"}],
125+ objectIds: [{$oid: "000000000000000000000001"}, null ],
126+ structAggregateEmbeddables: [{a: 1}, null ],
127+ charsCollection: ["s", "t", null, "r"],
128+ intsCollection: [null, 5],
129+ longsCollection: [{$numberLong: "9223372036854775807"}, null, {$numberLong: "6"}],
130+ doublesCollection: [null, {$numberDouble: "1.7976931348623157E308"}],
131+ booleansCollection: [null, true],
132+ stringsCollection: ["str", null ],
133+ bigDecimalsCollection: [{$numberDecimal: "10.1"}, null ],
134+ objectIdsCollection: [null, {$oid: "000000000000000000000001"}],
135+ structAggregateEmbeddablesCollection: [{a: 1}, null ]
137136 }
138137 """ );
139138 var loadedItem = sessionFactoryScope .fromTransaction (
@@ -158,24 +157,24 @@ void testArrayAndCollectionValues() {
158157 longs: [{$numberLong: "9223372036854775807"}, {$numberLong: "-6"}],
159158 doubles: [{$numberDouble: "1.7976931348623157E308"}],
160159 booleans: [true],
161- boxedChars: ["s", "t", "r"],
162- boxedInts: [7],
163- boxedLongs: [{$numberLong: "8"}],
164- boxedDoubles: [{$numberDouble: "9.1"}],
165- boxedBooleans: [true],
166- strings: ["str"],
167- bigDecimals: [{$numberDecimal: "10.1"}],
168- objectIds: [{$oid: "000000000000000000000002"}],
169- structAggregateEmbeddables: [{a: 1}],
170- charsCollection: ["s", "t", "r"],
171- intsCollection: [5],
172- longsCollection: [{$numberLong: "9223372036854775807"}, {$numberLong: "-6"}],
173- doublesCollection: [{$numberDouble: "1.7976931348623157E308"}],
174- booleansCollection: [true],
175- stringsCollection: ["str"],
176- bigDecimalsCollection: [{$numberDecimal: "10.1"}],
177- objectIdsCollection: [{$oid: "000000000000000000000001"}],
178- structAggregateEmbeddablesCollection: [{a: 1}]
160+ boxedChars: ["s", null, "t", "r"],
161+ boxedInts: [null, 7],
162+ boxedLongs: [{$numberLong: "8"}, null ],
163+ boxedDoubles: [{$numberDouble: "9.1"}, null ],
164+ boxedBooleans: [true, null ],
165+ strings: [null, "str"],
166+ bigDecimals: [null, {$numberDecimal: "10.1"}],
167+ objectIds: [{$oid: "000000000000000000000002"}, null ],
168+ structAggregateEmbeddables: [{a: 1}, null ],
169+ charsCollection: ["s", "t", null, "r"],
170+ intsCollection: [null, 5],
171+ longsCollection: [{$numberLong: "9223372036854775807"}, null, {$numberLong: "-6"}],
172+ doublesCollection: [null, {$numberDouble: "1.7976931348623157E308"}],
173+ booleansCollection: [null, true],
174+ stringsCollection: ["str", null ],
175+ bigDecimalsCollection: [{$numberDecimal: "10.1"}, null ],
176+ objectIdsCollection: [null, {$oid: "000000000000000000000001"}],
177+ structAggregateEmbeddablesCollection: [{a: 1}, null ]
179178 }
180179 """ );
181180 loadedItem = sessionFactoryScope .fromTransaction (
@@ -248,7 +247,6 @@ void testArrayAndCollectionEmptyValues() {
248247 }
249248
250249 @ Test
251- @ Disabled ("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test" )
252250 void testArrayAndCollectionNullValues () {
253251 var item = new ItemWithArrayAndCollectionValues (
254252 1 , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null ,
@@ -410,7 +408,6 @@ void testArrayAndCollectionValuesOfStructAggregateEmbeddablesHavingArraysAndColl
410408 * @see StructAggregateEmbeddableIntegrationTests#testNestedValueHavingNullArraysAndCollections()
411409 */
412410 @ Test
413- @ Disabled ("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test" )
414411 public void testArrayAndCollectionValuesOfEmptyStructAggregateEmbeddables () {
415412 var emptyStructAggregateEmbeddable = new ArraysAndCollections (
416413 null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null , null ,
@@ -597,16 +594,12 @@ static class ItemWithArrayAndCollectionValuesOfStructAggregateEmbeddablesHavingA
597594
598595 @ Nested
599596 class Unsupported {
600- /**
601- * The {@link ClassCastException} caught here manifests a Hibernate ORM bug. The issue goes away if the
602- * {@link ItemWithBoxedBytesArrayValue#bytes} field is removed. Otherwise, the behavior of this test should have
603- * been equivalent to {@link #testBytesCollectionValue()}.
604- */
597+
605598 @ Test
606599 void testBoxedBytesArrayValue () {
607600 var item = new ItemWithBoxedBytesArrayValue (1 , new byte [] {1 }, new Byte [] {2 });
608601 assertThatThrownBy (() -> sessionFactoryScope .inTransaction (session -> session .persist (item )))
609- .isInstanceOf ( ClassCastException .class );
602+ .hasCauseInstanceOf ( SQLFeatureNotSupportedException .class );
610603 }
611604
612605 @ Test
0 commit comments