@@ -188,19 +188,20 @@ void toObjectArrayWithEmptyPrimitiveArray() {
188
188
189
189
@ Test
190
190
void toObjectArrayWithNonArrayType () {
191
- assertThatIllegalArgumentException ().isThrownBy (() ->
192
- ObjectUtils .toObjectArray ("Not an []" ));
191
+ assertThatIllegalArgumentException ()
192
+ .isThrownBy (() -> ObjectUtils .toObjectArray ("Not an []" ))
193
+ .withMessageStartingWith ("Source is not an array" );
193
194
}
194
195
195
196
@ Test
196
197
void toObjectArrayWithNonPrimitiveArray () {
197
- String [] source = new String [] {"Bingo" };
198
- assertThat (ObjectUtils .toObjectArray (source )).isEqualTo (source );
198
+ String [] source = {"Bingo" };
199
+ assertThat (ObjectUtils .toObjectArray (source )).isSameAs (source );
199
200
}
200
201
201
202
@ Test
202
203
void addObjectToArraySunnyDay () {
203
- String [] array = new String [] {"foo" , "bar" };
204
+ String [] array = {"foo" , "bar" };
204
205
String newElement = "baz" ;
205
206
Object [] newArray = ObjectUtils .addObjectToArray (array , newElement );
206
207
assertThat (newArray ).hasSize (3 );
@@ -209,7 +210,7 @@ void addObjectToArraySunnyDay() {
209
210
210
211
@ Test
211
212
void addObjectToArraysAtPosition () {
212
- String [] array = new String [] {"foo" , "bar" , "baz" };
213
+ String [] array = {"foo" , "bar" , "baz" };
213
214
assertThat (ObjectUtils .addObjectToArray (array , "bat" , 3 )).containsExactly ("foo" , "bar" , "baz" , "bat" );
214
215
assertThat (ObjectUtils .addObjectToArray (array , "bat" , 2 )).containsExactly ("foo" , "bar" , "bat" , "baz" );
215
216
assertThat (ObjectUtils .addObjectToArray (array , "bat" , 1 )).containsExactly ("foo" , "bat" , "bar" , "baz" );
@@ -228,7 +229,7 @@ void addObjectToArrayWhenEmpty() {
228
229
@ Test
229
230
void addObjectToSingleNonNullElementArray () {
230
231
String existingElement = "foo" ;
231
- String [] array = new String [] {existingElement };
232
+ String [] array = {existingElement };
232
233
String newElement = "bar" ;
233
234
String [] newArray = ObjectUtils .addObjectToArray (array , newElement );
234
235
assertThat (newArray ).hasSize (2 );
@@ -238,7 +239,7 @@ void addObjectToSingleNonNullElementArray() {
238
239
239
240
@ Test
240
241
void addObjectToSingleNullElementArray () {
241
- String [] array = new String [] {null };
242
+ String [] array = {null };
242
243
String newElement = "bar" ;
243
244
String [] newArray = ObjectUtils .addObjectToArray (array , newElement );
244
245
assertThat (newArray ).hasSize (2 );
0 commit comments