NumberUtils { public static int requireNonNegative(int i, String message) { Objects.requireNonNull(message, "message must not be null"); if (i < 0) { throw new IllegalArgumentException(message); } return i; } private  NumberUtils(); static int requireNonNegative(int i, String message); static long requirePositive(long l, String message); static int requirePositive(int i, String message); static int requireUnsignedByte(int i); static int requireUnsignedMedium(int i); static int requireUnsignedShort(int i); static void encodeUnsignedMedium(ByteBuf byteBuf, int i); static final int MEDIUM_BYTES; }
@DisplayName("returns int value with postitive int") @Test void requireNonNegativeInt() { assertThat(NumberUtils.requireNonNegative(Integer.MAX_VALUE, "test-message")) .isEqualTo(Integer.MAX_VALUE); }
@DisplayName( "requireNonNegative with int argument throws IllegalArgumentException with negative value") @Test void requireNonNegativeIntNegative() { assertThatIllegalArgumentException() .isThrownBy(() -> NumberUtils.requireNonNegative(Integer.MIN_VALUE, "test-message")) .withMessage("test-message"); }
@DisplayName("requireNonNegative with int argument throws NullPointerException with null message") @Test void requireNonNegativeIntNullMessage() { assertThatNullPointerException() .isThrownBy(() -> NumberUtils.requireNonNegative(Integer.MIN_VALUE, null)) .withMessage("message must not be null"); }
@DisplayName("requireNonNegative returns int value with zero") @Test void requireNonNegativeIntZero() { assertThat(NumberUtils.requireNonNegative(0, "test-message")).isEqualTo(0); }