### Question:
ByteUtils { public static byte[] bigIntegerToBytes(final BigInteger value) { if (value == null) { return null; } byte[] data = value.toByteArray(); if (data.length != 1 && data[0] == 0) { byte[] tmp = new byte[data.length - 1]; System.arraycopy(data, 1, tmp, 0, tmp.length); data = tmp; } return data; }  static byte[] bigIntegerToBytes(final BigInteger value);  }### Answer:
@Test public void omitsSignIndicationByteProperly() { final BigInteger a = new BigInteger(1, Hex.decode("ff12345678")); final byte[] a5 = ByteUtils.bigIntegerToBytes(a); assertThat(a5.length).isEqualTo(5); assertThat(a5).containsExactly(Hex.decode("ff12345678")); final BigInteger b = new BigInteger(1, Hex.decode("0f12345678")); final byte[] b5 = ByteUtils.bigIntegerToBytes(b); assertThat(b5.length).isEqualTo(5); assertThat(b5).containsExactly(Hex.decode("0f12345678")); }
@Test public void ifParameterIsNullReturnsNull() { final byte[] a = ByteUtils.bigIntegerToBytes(null); assertThat(a).isNull(); }
@Test public void ifBigIntegerZeroReturnsZeroValueArray() { final byte[] a = ByteUtils.bigIntegerToBytes(BigInteger.ZERO); assertThat(a).containsExactly(0); }