### Question:
ByteFormatter { @NonNull public String formatArray(@NonNull final ByteFormat format, @Nullable final byte[] array) { if (array == null) { return "null"; } switch (format) { case INDIVIDUALLY_AS_ASCII: return formatAscii(array); case INDIVIDUALLY_AS_ASCII_WITH_UNICODE_SYMBOLS: return formatAsciiWithUnicode(array); case INDIVIDUALLY_AS_UNSIGNED_BYTE: return formatUnsignedByte(array); case INDIVIDUALLY_AS_SIGNED_BYTE: return formatSignedByte(array); default: throw new IllegalArgumentException("Unknown format: " + format); } } ByteFormatter(); @NonNull String formatArray(@NonNull final ByteFormat format,
                              @Nullable final byte[] array);  }### Answer:
@Test public void returnsNullStringForNullInput() { assertEquals("null", cut.formatArray(ByteFormat.INDIVIDUALLY_AS_ASCII, null)); }
@Test public void testSignedByteFormat() { final ByteFormat format = ByteFormat.INDIVIDUALLY_AS_SIGNED_BYTE; final byte[] input = new byte[]{-1, 0, 1, 65, 97, 127}; final String expected = "[-1, 0, 1, 65, 97, 127]"; assertEquals(expected, cut.formatArray(format, input)); }
@Test public void testUnsignedByteFormat() { final ByteFormat format = ByteFormat.INDIVIDUALLY_AS_UNSIGNED_BYTE; final byte[] input = new byte[]{-1, 0, 1, 65, 97, 127}; final String expected = "[255, 0, 1, 65, 97, 127]"; assertEquals(expected, cut.formatArray(format, input)); }
@Test public void testAsciiFormat() { final ByteFormat format = ByteFormat.INDIVIDUALLY_AS_ASCII; final byte[] input = new byte[]{-1, 0, 1, 65, 97, 127}; final String expected = "[\uFFFF, \u0000, \u0001, A, a, \u007F]"; assertEquals(expected, cut.formatArray(format, input)); }
@Test public void testAsciiWithUnicodeFormat() { final ByteFormat format = ByteFormat.INDIVIDUALLY_AS_ASCII_WITH_UNICODE_SYMBOLS; final byte[] input = new byte[]{-1, 0, 1, 65, 97, 127}; final String expected = "[\uFFFF, \u2400, \u2401, A, a, \u2421]"; assertEquals(expected, cut.formatArray(format, input)); }