NumberUtils { public static long requirePositive(long l, String message) { Objects.requireNonNull(message, "message must not be null"); if (l <= 0) { throw new IllegalArgumentException(message); } return l; } 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("requirePositive returns int value with positive int") @Test void requirePositiveInt() { assertThat(NumberUtils.requirePositive(Integer.MAX_VALUE, "test-message")) .isEqualTo(Integer.MAX_VALUE); }
@DisplayName( "requirePositive with int argument throws IllegalArgumentException with negative value") @Test void requirePositiveIntNegative() { assertThatIllegalArgumentException() .isThrownBy(() -> NumberUtils.requirePositive(Integer.MIN_VALUE, "test-message")) .withMessage("test-message"); }
@DisplayName("requirePositive with int argument throws NullPointerException with null message") @Test void requirePositiveIntNullMessage() { assertThatNullPointerException() .isThrownBy(() -> NumberUtils.requirePositive(Integer.MIN_VALUE, null)) .withMessage("message must not be null"); }
@DisplayName("requirePositive with int argument throws IllegalArgumentException with zero value") @Test void requirePositiveIntZero() { assertThatIllegalArgumentException() .isThrownBy(() -> NumberUtils.requirePositive(0, "test-message")) .withMessage("test-message"); }
@DisplayName("requirePositive returns long value with positive long") @Test void requirePositiveLong() { assertThat(NumberUtils.requirePositive(Long.MAX_VALUE, "test-message")) .isEqualTo(Long.MAX_VALUE); }
@DisplayName( "requirePositive with long argument throws IllegalArgumentException with negative value") @Test void requirePositiveLongNegative() { assertThatIllegalArgumentException() .isThrownBy(() -> NumberUtils.requirePositive(Long.MIN_VALUE, "test-message")) .withMessage("test-message"); }
@DisplayName("requirePositive with long argument throws NullPointerException with null message") @Test void requirePositiveLongNullMessage() { assertThatNullPointerException() .isThrownBy(() -> NumberUtils.requirePositive(Long.MIN_VALUE, null)) .withMessage("message must not be null"); }
@DisplayName("requirePositive with long argument throws IllegalArgumentException with zero value") @Test void requirePositiveLongZero() { assertThatIllegalArgumentException() .isThrownBy(() -> NumberUtils.requirePositive(0L, "test-message")) .withMessage("test-message"); }