### Question:
HexUtils { public static String prettyHexString(String hexString) { if (hexString == null) throw new NullPointerException("Hexadecimal string cannot be null."); String copy = hexString.toUpperCase(); for (final char c : copy.toCharArray()) { if (!HEXES.contains(""+c)) throw new IllegalArgumentException("Given string cannot contain non-hexadecimal characters."); } String prettyHexString = ""; if (copy.length() % 2 != 0) copy = "0" + copy; int iterations = copy.length() / 2; for (int i = 0; i < iterations; i++) prettyHexString += copy.substring(2 * i, 2 * i + 2) + " "; return prettyHexString.trim(); }  static String byteArrayToHexString(byte[] value); static String byteToHexString(byte value); static byte[] hexStringToByteArray(String value); static boolean containsLetters(String parameter); static String integerToHexString(int value, int minBytes); static String prettyHexString(String hexString); static String prettyHexString(byte[] value);  }### Answer:
@Test public final void testPrettyHexStringNullString() { String s = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("Hexadecimal string cannot be null."))); HexUtils.prettyHexString(s); }
@Test public final void testPrettyHexStringNonHexadecimalString() { String s = "tyurw"; exception.expect(IllegalArgumentException.class); exception.expectMessage(is(equalTo("Given string cannot contain non-hexadecimal characters."))); HexUtils.prettyHexString(s); }
@Test public final void testPrettyHexStringEmptyString() { String s = ""; String expectedResult = ""; String result = HexUtils.prettyHexString(s); assertThat("Returned string must be equal to 'expectedResult'", result, is(equalTo(expectedResult))); }
@Test public final void testPrettyHexStringGeneral() { String s = "1e2589d3a896f47c90b"; String expectedResult = "01 E2 58 9D 3A 89 6F 47 C9 0B"; String result = HexUtils.prettyHexString(s); assertThat("Returned string must be equal to 'expectedResult'", result, is(equalTo(expectedResult))); }
@Test public final void testPrettyHexStringNullByteArray() { byte[] array = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("Value to convert cannot be null."))); HexUtils.prettyHexString(array); }
@Test public final void testPrettyHexStringEmptyByteArray() { byte[] array = new byte[0]; String expectedResult = ""; String result = HexUtils.prettyHexString(array); assertThat("Returned string must be equal to 'expectedResult'", result, is(equalTo(expectedResult))); }
@Test public final void testPrettyHexStringWithByteArrayGeneral() { byte[] array = new byte[]{0x01, (byte)0xe2, 0x58, (byte)0x9d, 0x3a, (byte)0x89, 0x6f, 0x47, (byte)0xc9, 0x0b}; String expectedResult = "01 E2 58 9D 3A 89 6F 47 C9 0B"; String result = HexUtils.prettyHexString(array); assertThat("Returned string must be equal to 'expectedResult'", result, is(equalTo(expectedResult))); }
@Test public final void testPrettyHexStringWithByteArrayNonHexChars() { byte[] array = "tyurw".getBytes(); String expectedResult = "74 79 75 72 77"; String result = HexUtils.prettyHexString(array); assertThat("Returned string must be equal to 'expectedResult'", result, is(equalTo(expectedResult))); }