### Question:
ByteUtil { public static byte toByteExactUnsigned(final int value) throws IllegalArgumentException { checkArgument(value >= 0, "Supplied int value (%s) is negative", value); return castToByteExact(value); }  static int toUnsignedInt(final byte value); static byte toByteExact(final int value); static byte toByteExactUnsigned(final int value);  }### Answer:
@Test public void toByteExactUnsigned_maxValue() { final int value = 255; byte byteValue = ByteUtil.toByteExactUnsigned(value); assertThat(byteValue).isEqualTo((byte) value); }
@Test public void toByteExactUnsigned_minNegativeValue() { final int value = -128; assertThatThrownBy(() -> ByteUtil.toByteExactUnsigned(value)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Supplied int value (-128) is negative"); }
@Test public void toByteExactUnsigned_0xFFasNegative() { final int value = -1; assertThatThrownBy(() -> ByteUtil.toByteExactUnsigned(value)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Supplied int value (-1) is negative"); }
@Test public void toByteExactUnsigned_minPositiveValue() { final int value = 1; byte byteValue = ByteUtil.toByteExactUnsigned(value); assertThat(byteValue).isEqualTo((byte) value); }
@Test public void toByteExactUnsigned_zero() { final int value = 0; byte byteValue = ByteUtil.toByteExactUnsigned(value); assertThat(byteValue).isEqualTo((byte) value); }
@Test public void toByteExactUnsigned_valueTooLarge() { assertThatThrownBy(() -> ByteUtil.toByteExactUnsigned(256)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Supplied int value (256) overflows byte"); }
@Test public void toByteExactUnsigned_valueTooSmall() { assertThatThrownBy(() -> ByteUtil.toByteExactUnsigned(-129)) .isInstanceOf(IllegalArgumentException.class); }