Polishing
This commit is contained in:
@@ -288,9 +288,9 @@ public abstract class ObjectUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given array (which may be a primitive array) to an
|
||||
* object array (if necessary of primitive wrapper objects).
|
||||
* <p>A {@code null} source value will be converted to an
|
||||
* Convert the given array (which may be a primitive array) to an object array (if
|
||||
* necessary, to an array of primitive wrapper objects).
|
||||
* <p>A {@code null} source value or empty primitive array will be converted to an
|
||||
* empty Object array.
|
||||
* @param source the (potentially primitive) array
|
||||
* @return the corresponding object array (never {@code null})
|
||||
|
||||
@@ -188,19 +188,20 @@ class ObjectUtilsTests {
|
||||
|
||||
@Test
|
||||
void toObjectArrayWithNonArrayType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ObjectUtils.toObjectArray("Not an []"));
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ObjectUtils.toObjectArray("Not an []"))
|
||||
.withMessageStartingWith("Source is not an array");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toObjectArrayWithNonPrimitiveArray() {
|
||||
String[] source = new String[] {"Bingo"};
|
||||
assertThat(ObjectUtils.toObjectArray(source)).isEqualTo(source);
|
||||
String[] source = {"Bingo"};
|
||||
assertThat(ObjectUtils.toObjectArray(source)).isSameAs(source);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addObjectToArraySunnyDay() {
|
||||
String[] array = new String[] {"foo", "bar"};
|
||||
String[] array = {"foo", "bar"};
|
||||
String newElement = "baz";
|
||||
Object[] newArray = ObjectUtils.addObjectToArray(array, newElement);
|
||||
assertThat(newArray).hasSize(3);
|
||||
@@ -209,7 +210,7 @@ class ObjectUtilsTests {
|
||||
|
||||
@Test
|
||||
void addObjectToArraysAtPosition() {
|
||||
String[] array = new String[] {"foo", "bar", "baz"};
|
||||
String[] array = {"foo", "bar", "baz"};
|
||||
assertThat(ObjectUtils.addObjectToArray(array, "bat", 3)).containsExactly("foo", "bar", "baz", "bat");
|
||||
assertThat(ObjectUtils.addObjectToArray(array, "bat", 2)).containsExactly("foo", "bar", "bat", "baz");
|
||||
assertThat(ObjectUtils.addObjectToArray(array, "bat", 1)).containsExactly("foo", "bat", "bar", "baz");
|
||||
@@ -228,7 +229,7 @@ class ObjectUtilsTests {
|
||||
@Test
|
||||
void addObjectToSingleNonNullElementArray() {
|
||||
String existingElement = "foo";
|
||||
String[] array = new String[] {existingElement};
|
||||
String[] array = {existingElement};
|
||||
String newElement = "bar";
|
||||
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
|
||||
assertThat(newArray).hasSize(2);
|
||||
@@ -238,7 +239,7 @@ class ObjectUtilsTests {
|
||||
|
||||
@Test
|
||||
void addObjectToSingleNullElementArray() {
|
||||
String[] array = new String[] {null};
|
||||
String[] array = {null};
|
||||
String newElement = "bar";
|
||||
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
|
||||
assertThat(newArray).hasSize(2);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MediaTypeAssert extends AbstractObjectAssert<MediaTypeAssert, Media
|
||||
* representation.
|
||||
* @param mediaType the expected media type, as a String to be parsed
|
||||
* into a MediaType
|
||||
*/
|
||||
*/
|
||||
public MediaTypeAssert isEqualTo(String mediaType) {
|
||||
return isEqualTo(parseMediaType(mediaType));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user