### Question:
Utils { static byte[] hexEncode(byte[] in) { if (in == null) { return null; } byte[] ret = new byte[in.length << 1]; for (int i = 0; i < in.length; i++) { int v = in[i] & 0xff; ret[i << 1] = hexMap.get((char) encodingTable[v >>> 4]); ret[(i << 1) + 1] = hexMap.get((char) encodingTable[v & 0xf]); } return ret; }    }### Answer:
@Test public void testHexEncode_wNull() { assertThat(Utils.hexEncode(null)).isNull(); }
@Test public void testHexEncode_wSingleByte() { for (byte b : encodingTable) { byte[] input = new byte[] {b}; byte[] rlpHexEncodeOutput = Utils.hexEncode(input); byte[] hexEncodeOutput = Hex.encode(input); assertEquals(rlpHexEncodeOutput.length, hexEncodeOutput.length); for (int i = 0; i < rlpHexEncodeOutput.length; i++) { assertThat(rlpHexEncodeOutput[i]) .isEqualTo(hexMap.get((char) encodingTable[hexEncodeOutput[i] & 0xf])); } } }
@Test public void testHexEncode_woTerminatorByte() { String value = "1234567890abcdef"; byte[] input = Hex.decode(value); byte[] rlpHexEncodeOutput = Utils.hexEncode(input); byte[] expectOutput = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15}; assertArrayEquals(rlpHexEncodeOutput, expectOutput); }