### Question:
PathEncoder { @Nonnull static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private  PathEncoder();   }### Answer:
@Test public void encodeNullBinaryPath() { try { PathEncoder.encode(null); Assert.fail(); } catch (Exception ex) { Assert.assertTrue(ex instanceof IllegalArgumentException); } }
@Test public void encodeBinaryPathOneByte() { byte[] path = new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01 }; byte[] encoded = PathEncoder.encode(path); Assert.assertNotNull(encoded); Assert.assertArrayEquals(new byte[] { 0x6d }, encoded); }
@Test public void encodeBinaryPathNineBits() { byte[] path = new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01 }; byte[] encoded = PathEncoder.encode(path); Assert.assertNotNull(encoded); Assert.assertArrayEquals(new byte[] { 0x6d, (byte)0x80 }, encoded); }
@Test public void encodeBinaryPathOneAndHalfByte() { byte[] path = new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 }; byte[] encoded = PathEncoder.encode(path); Assert.assertNotNull(encoded); Assert.assertArrayEquals(new byte[] { 0x6d, 0x50 }, encoded); }