### Question:
ByteArrayUtils { public static byte[] fromHex(String hex) { hex = HEX_IGNORED_CHARS.matcher(hex).replaceAll("").toUpperCase(); if (hex.length() % 2 != 0) { throw new IllegalArgumentException("Odd numbered hex array"); } byte[] byteArray = new byte[hex.length() / 2]; for (int i = 0; i < hex.length(); i += 2) { byteArray[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) + Character.digit(hex.charAt(i + 1), 16)); } return byteArray; }  static byte[] fromHex(String hex); static String toHex(byte[] byteArray); static int threeBytesToInt(byte[] bytes, int offset);  }### Answer:
@Test(expected = NullPointerException.class) public void fromHex_null() { byte[] bytes = ByteArrayUtils.fromHex(null); }
@Test public void fromHex_empty() { byte[] bytes = ByteArrayUtils.fromHex(""); assertEquals(bytes.length, 0); }
@Test(expected = IllegalArgumentException.class) public void fromHex_odd_length() { byte[] bytes = ByteArrayUtils.fromHex(HEXSTRING_ODD); }
@Test public void fromHex_bad_hex() { byte[] bytes = ByteArrayUtils.fromHex(HEXSTRING_BAD); }
@Test public void fromHex_good_hex() { byte[] bytes = ByteArrayUtils.fromHex(HEXSTRING_GOOD); assertArrayEquals(bytes, BYTEARRAY_GOOD); }