### Question:
HexUtils { public static byte[] hexStringToByteArray(String value) { if (value == null) throw new NullPointerException("Value to convert cannot be null."); value = value.trim(); if (value.startsWith(HEX_HEADER)) value = value.substring((HEX_HEADER).length()); int len = value.length(); if (len % 2 != 0) { value = "0" + value; len = value.length(); } byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(value.charAt(i), 16) << 4) + Character.digit(value.charAt(i+1), 16)); } return data; }  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 testHexStringToByteArrayNullString() { String s = null; exception.expect(NullPointerException.class); exception.expectMessage(is(equalTo("Value to convert cannot be null."))); HexUtils.hexStringToByteArray(s); }
@Test public final void testHexStringToByteArrayEmptyStrng() { String s = ""; byte[] expectedResult = new byte[0]; byte[] result = HexUtils.hexStringToByteArray(s); assertThat("Returned byte array must be equal to 'expectedResult'", result, is(equalTo(expectedResult))); }
@Test public final void testHexStringToByteArray() { String s = "0102030405"; byte[] expectedResult = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05}; byte[] result = HexUtils.hexStringToByteArray(s); assertThat("Returned byte array must be equal to 'expectedResult'", result, is(equalTo(expectedResult))); }