|
19 | 19 |
|
20 | 20 | import org.hibernate.reactive.BaseReactiveTest;
|
21 | 21 |
|
22 |
| - |
23 | 22 | import org.junit.jupiter.api.Test;
|
24 | 23 | import org.junit.jupiter.api.condition.DisabledIf;
|
25 | 24 |
|
|
41 | 40 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
42 | 41 |
|
43 | 42 | @Timeout(value = 10, timeUnit = MINUTES)
|
44 |
| -@DisabledIf( "isNotSupported" ) |
| 43 | +@DisabledIf("isNotSupported") |
45 | 44 | public class JavaTypesArrayTest extends BaseReactiveTest {
|
46 | 45 |
|
47 | 46 | @Override
|
@@ -80,48 +79,93 @@ public void testStringArrayType(VertxTestContext context) {
|
80 | 79 | @Test
|
81 | 80 | public void testBooleanArrayType(VertxTestContext context) {
|
82 | 81 | Basic basic = new Basic();
|
83 |
| - Boolean[] dataArray = {TRUE, FALSE, TRUE}; |
| 82 | + Boolean[] dataArray = {TRUE, FALSE, null, TRUE}; |
84 | 83 | basic.booleanArray = dataArray;
|
85 | 84 |
|
86 | 85 | testField( context, basic, found -> assertArrayEquals( dataArray, found.booleanArray ) );
|
87 | 86 | }
|
88 | 87 |
|
| 88 | + @Test |
| 89 | + public void testPrimitiveBooleanArrayType(VertxTestContext context) { |
| 90 | + Basic basic = new Basic(); |
| 91 | + boolean[] dataArray = {true, false, true}; |
| 92 | + basic.primitiveBooleanArray = dataArray; |
| 93 | + |
| 94 | + testField( context, basic, found -> assertArrayEquals( dataArray, found.primitiveBooleanArray ) ); |
| 95 | + } |
| 96 | + |
89 | 97 | @Test
|
90 | 98 | public void testIntegerArrayType(VertxTestContext context) {
|
91 | 99 | Basic basic = new Basic();
|
92 |
| - Integer[] dataArray = {1, 2, 3}; |
| 100 | + Integer[] dataArray = {null, Integer.MIN_VALUE, 2, Integer.MAX_VALUE}; |
93 | 101 | basic.integerArray = dataArray;
|
94 | 102 |
|
95 | 103 | testField( context, basic, found -> assertArrayEquals( dataArray, found.integerArray ) );
|
96 | 104 | }
|
97 | 105 |
|
| 106 | + @Test |
| 107 | + public void testPrimitiveIntegerArrayType(VertxTestContext context) { |
| 108 | + Basic basic = new Basic(); |
| 109 | + int[] dataArray = {1, 2, 3}; |
| 110 | + basic.primitiveIntegerArray = dataArray; |
| 111 | + |
| 112 | + testField( context, basic, found -> assertArrayEquals( dataArray, found.primitiveIntegerArray ) ); |
| 113 | + } |
| 114 | + |
98 | 115 | @Test
|
99 | 116 | public void testLongArrayType(VertxTestContext context) {
|
100 | 117 | Basic basic = new Basic();
|
101 |
| - Long[] dataArray = {Long.MIN_VALUE, Long.MAX_VALUE, 3L}; |
| 118 | + Long[] dataArray = {Long.MIN_VALUE, Long.MAX_VALUE, 3L, null}; |
102 | 119 | basic.longArray = dataArray;
|
103 | 120 |
|
104 | 121 | testField( context, basic, found -> assertArrayEquals( dataArray, found.longArray ) );
|
105 | 122 | }
|
106 | 123 |
|
| 124 | + @Test |
| 125 | + public void testPrimitiveLongArrayType(VertxTestContext context) { |
| 126 | + Basic basic = new Basic(); |
| 127 | + long[] dataArray = {Long.MIN_VALUE, Long.MAX_VALUE, 3L}; |
| 128 | + basic.primitiveLongArray = dataArray; |
| 129 | + |
| 130 | + testField( context, basic, found -> assertArrayEquals( dataArray, found.primitiveLongArray ) ); |
| 131 | + } |
| 132 | + |
107 | 133 | @Test
|
108 | 134 | public void testFloatArrayType(VertxTestContext context) {
|
109 | 135 | Basic basic = new Basic();
|
110 |
| - Float[] dataArray = {12.562f, 13.562f}; |
| 136 | + Float[] dataArray = {12.562f, null, 13.562f}; |
111 | 137 | basic.floatArray = dataArray;
|
112 | 138 |
|
113 | 139 | testField( context, basic, found -> assertArrayEquals( dataArray, found.floatArray ) );
|
114 | 140 | }
|
115 | 141 |
|
| 142 | + @Test |
| 143 | + public void testPrimitiveFloatArrayType(VertxTestContext context) { |
| 144 | + Basic basic = new Basic(); |
| 145 | + float[] dataArray = {12.562f, 13.562f}; |
| 146 | + basic.primitiveFloatArray = dataArray; |
| 147 | + |
| 148 | + testField( context, basic, found -> assertArrayEquals( dataArray, found.primitiveFloatArray ) ); |
| 149 | + } |
| 150 | + |
116 | 151 | @Test
|
117 | 152 | public void testDoubleArrayType(VertxTestContext context) {
|
118 | 153 | Basic basic = new Basic();
|
119 |
| - Double[] dataArray = {12.562d, 13.562d}; |
| 154 | + Double[] dataArray = {12.562d, null, 13.562d}; |
120 | 155 | basic.doubleArray = dataArray;
|
121 | 156 |
|
122 | 157 | testField( context, basic, found -> assertArrayEquals( dataArray, found.doubleArray ) );
|
123 | 158 | }
|
124 | 159 |
|
| 160 | + @Test |
| 161 | + public void testPrimitiveDoubleArrayType(VertxTestContext context) { |
| 162 | + Basic basic = new Basic(); |
| 163 | + double[] dataArray = {12.562d, 13.562d}; |
| 164 | + basic.primitiveDoubleArray = dataArray; |
| 165 | + |
| 166 | + testField( context, basic, found -> assertArrayEquals( dataArray, found.primitiveDoubleArray ) ); |
| 167 | + } |
| 168 | + |
125 | 169 | @Test
|
126 | 170 | public void testUUIDArrayType(VertxTestContext context) {
|
127 | 171 | Basic basic = new Basic();
|
@@ -153,6 +197,15 @@ public void testShortArrayType(VertxTestContext context) {
|
153 | 197 | testField( context, basic, found -> assertArrayEquals( dataArray, found.shortArray ) );
|
154 | 198 | }
|
155 | 199 |
|
| 200 | + @Test |
| 201 | + public void testPrimitiveShortArrayType(VertxTestContext context) { |
| 202 | + Basic basic = new Basic(); |
| 203 | + short[] dataArray = {500, 32, -1}; |
| 204 | + basic.primitiveShortArray = dataArray; |
| 205 | + |
| 206 | + testField( context, basic, found -> assertArrayEquals( dataArray, found.primitiveShortArray ) ); |
| 207 | + } |
| 208 | + |
156 | 209 | @Test
|
157 | 210 | public void testLocalDateArrayType(VertxTestContext context) {
|
158 | 211 | Basic basic = new Basic();
|
@@ -238,18 +291,26 @@ private static class Basic {
|
238 | 291 | Integer id;
|
239 | 292 | String[] stringArray;
|
240 | 293 | Boolean[] booleanArray;
|
241 |
| - |
| 294 | + boolean[] primitiveBooleanArray; |
242 | 295 | Integer[] integerArray;
|
| 296 | + int[] primitiveIntegerArray; |
243 | 297 | Long[] longArray;
|
| 298 | + long[] primitiveLongArray; |
244 | 299 | Float[] floatArray;
|
| 300 | + float[] primitiveFloatArray; |
245 | 301 | Double[] doubleArray;
|
| 302 | + double[] primitiveDoubleArray; |
246 | 303 | UUID[] uuidArray;
|
247 | 304 | AnEnum[] enumArray;
|
248 | 305 | Short[] shortArray;
|
| 306 | + short[] primitiveShortArray; |
249 | 307 | Date[] dateArray;
|
250 | 308 | LocalDate[] localDateArray;
|
251 | 309 | LocalTime[] localTimeArray;
|
252 | 310 | LocalDateTime[] localDateTimeArray;
|
| 311 | + |
| 312 | + // We have to specify the length for BigDecimal and BigInteger because |
| 313 | + // the default column type when creating the schema is too small on some databases |
253 | 314 | @Column(length = 5000)
|
254 | 315 | BigInteger[] bigIntegerArray;
|
255 | 316 | @Column(length = 5000)
|
|
0 commit comments