ArrayUtils { public static String toString(final Object... array) { final StringBuilder buffer = new StringBuilder("["); int count = 0; if (array != null) { for (final Object element : array) { buffer.append(count++ > 0 ? ", " : StringUtils.EMPTY).append(element); } } buffer.append("]"); return buffer.toString(); }  static T getElementAtIndex(T[] array, int index, T defaultValue); static T getFirst(final T... array); static String toString(final Object... array); static String toString(final String... array); static Object[] insert(Object[] originalArray, int pos, Object element); static Object[] remove(Object[] originalArray, int pos); static String objectRefString(Object obj); static void objectRefString(Object obj, StringBuilder sb); static String objectString(Object obj); static void objectString(Object obj, StringBuilder sb); static String objectStringNonRecursive(@Unretained Object obj); static boolean areByteArrayArrayEquals(byte[][] v1, byte[][] v2); static void objectStringNonRecursive(@Unretained Object obj, StringBuilder sb); static boolean objectEquals(Object o1, Object o2); static Integer[] toIntegerArray(final int[] array); static Byte[][] toByteArray(final byte[][] array); static byte[][] toBytes(final Byte[][] byteArray); static List<T> asList(T... array);  }
@Test public void toString_returnsOrderedStringInBrackets() { Object[] arrayOfThree = new Object[] {"test", "testing", "tested"}; assertThat(ArrayUtils.toString(arrayOfThree)).isEqualTo("[test, testing, tested]"); }
@Test public void toString_empty_returnsEmptyBrackets() { assertThat(ArrayUtils.toString((new Object[0]))).isEqualTo("[]"); }
@Test public void toString_null_returnsEmptyBrackets() { assertThat(ArrayUtils.toString((Object[]) null)).isEqualTo("[]"); }