diff --git a/common/src/main/java/com/hedera/block/common/utils/Preconditions.java b/common/src/main/java/com/hedera/block/common/utils/Preconditions.java index 64dda396..d2909a15 100644 --- a/common/src/main/java/com/hedera/block/common/utils/Preconditions.java +++ b/common/src/main/java/com/hedera/block/common/utils/Preconditions.java @@ -16,130 +16,126 @@ package com.hedera.block.common.utils; -import java.util.Objects; +import edu.umd.cs.findbugs.annotations.NonNull; /** A utility class used to assert various preconditions. */ -public final class Preconditions { // @todo(381) change the APIs to accept non-null error messages +public final class Preconditions { + private static final String DEFAULT_NOT_BLANK_MESSAGE = "The input String is required to be non-blank."; + private static final String DEFAULT_REQUIRE_POSITIVE_MESSAGE = "The input number [%d] is required to be positive."; + private static final String DEFAULT_GT_OR_EQ_MESSAGE = + "The input number [%d] is required to be greater or equal than [%d]."; + private static final String DEFAULT_REQUIRE_IN_RANGE_MESSAGE = + "The input number [%d] is required to be in the range [%d, %d] boundaries included."; + private static final String DEFAULT_REQUIRE_WHOLE_MESSAGE = + "The input number [%d] is required to be a whole number."; + private static final String DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE = + "The input number [%d] is required to be a power of two."; + /** - * This method asserts a given {@link String} is not blank, meaning it is - * not {@code null} or does not contain only whitespaces as defined by - * {@link String#isBlank()}. If the given {@link String} is not blank, then - * we return it, else we throw {@link IllegalArgumentException}. + * This method asserts a given {@link String} is not blank. + * A blank {@link String} is one that is either {@code null} or contains + * only whitespaces as defined by {@link String#isBlank()}. If the given + * {@link String} is not blank, then we return it, else we throw an + * {@link IllegalArgumentException}. * - * @param toCheck a {@link String} to be checked if is blank as defined - * above - * @return the {@link String} to be checked if it is not blank as defined - * above + * @param toCheck a {@link String} to be checked if is blank as defined above + * @return the {@link String} to be checked if it is not blank as defined above * @throws IllegalArgumentException if the input {@link String} to be - * checked is blank + * checked is blank */ public static String requireNotBlank(final String toCheck) { - return requireNotBlank(toCheck, null); + return requireNotBlank(toCheck, DEFAULT_NOT_BLANK_MESSAGE); } /** - * This method asserts a given {@link String} is not blank, meaning it is - * not {@code null} or does not contain only whitespaces as defined by - * {@link String#isBlank()}. If the given {@link String} is not blank, then - * we return it, else we throw {@link IllegalArgumentException}. + * This method asserts a given {@link String} is not blank. + * A blank {@link String} is one that is either {@code null} or contains + * only whitespaces as defined by {@link String#isBlank()}. If the given + * {@link String} is not blank, then we return it, else we throw an + * {@link IllegalArgumentException}. * - * @param toCheck a {@link String} to be checked if is blank as defined - * above - * @param errorMessage the error message to be used in the exception if the - * input {@link String} to be checked is blank, if null, a - * default message - * @return the {@link String} to be checked if it is not blank as defined - * above + * @param toCheck a {@link String} to be checked if is blank as defined above + * @param errorMessage the error message to be used if the precondition + * check fails, must not be {@code null} + * @return the {@link String} to be checked if it is not blank as defined above * @throws IllegalArgumentException if the input {@link String} to be - * checked is blank + * checked is blank */ - public static String requireNotBlank(final String toCheck, final String errorMessage) { + public static String requireNotBlank(final String toCheck, @NonNull final String errorMessage) { if (StringUtilities.isBlank(toCheck)) { - final String message = - Objects.isNull(errorMessage) ? "The input String is required to be non-blank." : errorMessage; - throw new IllegalArgumentException(message); + throw new IllegalArgumentException(errorMessage); } else { return toCheck; } } /** - * This method asserts a given integer is a positive. An integer is positive - * if it is NOT equal to zero and is greater than zero. + * This method asserts a given integer is a positive. + * An integer is positive if it is NOT equal to zero and is greater than zero. * * @param toCheck the number to check if it is a positive power of two * @return the number to check if it is positive - * @throws IllegalArgumentException if the input number to check is not - * positive + * @throws IllegalArgumentException if the input number to check is not positive */ public static int requirePositive(final int toCheck) { - return requirePositive(toCheck, null); + return requirePositive(toCheck, DEFAULT_REQUIRE_POSITIVE_MESSAGE); } /** - * This method asserts a given integer is a positive. An integer is positive - * if it is NOT equal to zero and is greater than zero. + * This method asserts a given integer is a positive. + * An integer is positive if it is NOT equal to zero and is greater than zero. * - * @param toCheck the integer to check if it is a positive power of two - * @param errorMessage the error message to be used in the exception if the - * input integer to check is not positive, if null, a - * default message will - * be used + * @param toCheck the integer to check if it is a positive power of two + * @param errorMessage a formatted string with one decimal parameters for + * {@code toCheck}, must not be {@code null}.
+ * Example error message: {@value #DEFAULT_REQUIRE_POSITIVE_MESSAGE} * @return the number to check if it is positive - * @throws IllegalArgumentException if the input number to check is not - * positive + * @throws IllegalArgumentException if the input integer to check is not positive + * @see java.util.Formatter for more information on error message formatting */ - public static int requirePositive(final int toCheck, final String errorMessage) { + public static int requirePositive(final int toCheck, @NonNull final String errorMessage) { if (0 >= toCheck) { - final String message = Objects.isNull(errorMessage) - ? "The input integer [%d] is required be positive.".formatted(toCheck) - : errorMessage; - throw new IllegalArgumentException(message); + throw new IllegalArgumentException(errorMessage.formatted(toCheck)); } else { return toCheck; } } /** - * This method asserts a given long is a positive. A long is positive - * if it is NOT equal to zero and is greater than zero. + * This method asserts a given long is a positive. + * A long is positive if it is NOT equal to zero and is greater than zero. * * @param toCheck the long to check if it is a positive power of two * @return the long to check if it is positive - * @throws IllegalArgumentException if the input long to check is not - * positive + * @throws IllegalArgumentException if the input long to check is not positive */ public static long requirePositive(final long toCheck) { - return requirePositive(toCheck, null); + return requirePositive(toCheck, DEFAULT_REQUIRE_POSITIVE_MESSAGE); } /** - * This method asserts a given long is a positive. A long is positive - * if it is NOT equal to zero and is greater than zero. + * This method asserts a given long is a positive. + * A long is positive if it is NOT equal to zero and is greater than zero. * - * @param toCheck the long to check if it is a positive power of two - * @param errorMessage the error message to be used in the exception if the - * input long to check is not positive, if null, a default - * message will - * be used - * @return the long to check if it is positive - * @throws IllegalArgumentException if the input long to check is not - * positive + * @param toCheck the long to check if it is a positive power of two + * @param errorMessage a formatted string with one decimal parameters for + * {@code toCheck}, must not be {@code null}.
+ * Example error message: {@value #DEFAULT_REQUIRE_POSITIVE_MESSAGE} + * @return the number to check if it is positive + * @throws IllegalArgumentException if the input long to check is not positive + * @see java.util.Formatter for more information on error message formatting */ - public static long requirePositive(final long toCheck, final String errorMessage) { + public static long requirePositive(final long toCheck, @NonNull final String errorMessage) { if (0L >= toCheck) { - final String message = Objects.isNull(errorMessage) - ? "The input long [%d] is required be positive.".formatted(toCheck) - : errorMessage; - throw new IllegalArgumentException(message); + throw new IllegalArgumentException(errorMessage.formatted(toCheck)); } else { return toCheck; } } /** - * Ensures that a given long value is greater than or equal to a specified base - * value. + * Ensures that a given long value is greater than or equal to a specified + * base value. * If the value does not meet the requirement, an * {@link IllegalArgumentException} is thrown. * @@ -151,118 +147,106 @@ public static long requirePositive(final long toCheck, final String errorMessage * * @param toTest the long value to test * @param base the base value to compare against - * @return the input {@code toTest} if it is greater than or equal to - * {@code base} + * @return the input {@code toTest} if it is greater than or equal to {@code base} * @throws IllegalArgumentException if {@code toTest} is less than {@code base} */ public static long requireGreaterOrEqual(final long toTest, final long base) { - return requireGreaterOrEqual(toTest, base, null); + return requireGreaterOrEqual(toTest, base, DEFAULT_GT_OR_EQ_MESSAGE); } /** - * Ensures that a given long value is greater than or equal to a specified base - * value. + * Ensures that a given long value is greater than or equal to a specified + * base value. * If the value does not meet the requirement, an * {@link IllegalArgumentException} is thrown. * - * @param toTest the long value to test - * @param base the base value to compare against - * @param errorMessage the error message to include in the exception if the - * check fails; - * if {@code null}, a default message is used - * @return the input {@code toTest} if it is greater than or equal to - * {@code base} - * @throws IllegalArgumentException if {@code toTest} is less than {@code base} + * @param toTest the long value to test + * @param base the base value to compare against + * @param errorMessage a formatted string with two decimal parameters for + * {@code toTest} and {@code base}, must not be {@code null}.
+ * Example error message: {@value #DEFAULT_GT_OR_EQ_MESSAGE} + * @return the number to check if it is greater than or equal to the base + * @throws IllegalArgumentException if the input long toTest is not greater + * than or equal to the base + * @see java.util.Formatter for more information on error message formatting */ - public static long requireGreaterOrEqual(final long toTest, final long base, final String errorMessage) { + public static long requireGreaterOrEqual(final long toTest, final long base, @NonNull final String errorMessage) { if (toTest >= base) { return toTest; + } else { + throw new IllegalArgumentException(errorMessage.formatted(toTest, base)); } - - final String message = Objects.isNull(errorMessage) - ? "The input integer [%d] is required be greater or equal than [%d].".formatted(toTest, base) - : errorMessage; - throw new IllegalArgumentException(message); } /** - * This method asserts a given int is within a range (boundaries - * included). If the given int is within the range, then we return it, - * else, an {@link IllegalArgumentException} is thrown. + * This method asserts a given int is within a range (boundaries included). + * If the given int is within the range, then we return it, else, an + * {@link IllegalArgumentException} is thrown. * * @param toCheck the int value to test * @param lowerBoundary the lower boundary * @param upperBoundary the upper boundary - * @return the input {@code toCheck} if it is within the range (boundaries - * included) + * @return the input {@code toCheck} if it is within the range (boundaries included) * @throws IllegalArgumentException if the input int does not pass the test */ public static int requireInRange(final int toCheck, final int lowerBoundary, final int upperBoundary) { - return requireInRange(toCheck, lowerBoundary, upperBoundary, null); + return requireInRange(toCheck, lowerBoundary, upperBoundary, DEFAULT_REQUIRE_IN_RANGE_MESSAGE); } /** - * This method asserts a given int is within a range (boundaries - * included). If the given int is within the range, then we return it, - * else, an {@link IllegalArgumentException} is thrown. + * This method asserts a given int is within a range (boundaries included). + * If the given int is within the range, then we return it, else, an + * {@link IllegalArgumentException} is thrown. * * @param toCheck the int value to check * @param lowerBoundary the lower boundary * @param upperBoundary the upper boundary - * @param errorMessage the error message to be used in the exception if the - * input int to test is not within the range, if null, a default message - * will be used - * @return the input {@code toCheck} if it is within the range (boundaries - * included) + * @param errorMessage a formatted string with three decimal parameters for + * {@code toTest}, {@code upperBoundary} and {@code lowerBoundary}, must not + * be {@code null}.
+ * Example error message: {@value #DEFAULT_REQUIRE_IN_RANGE_MESSAGE} + * @return the input {@code toCheck} if it is within the range (boundaries included) * @throws IllegalArgumentException if the input int does not pass the test + * @see java.util.Formatter for more information on error message formatting */ public static int requireInRange( - final int toCheck, final int lowerBoundary, final int upperBoundary, final String errorMessage) { + final int toCheck, final int lowerBoundary, final int upperBoundary, @NonNull final String errorMessage) { if (toCheck >= lowerBoundary && toCheck <= upperBoundary) { return toCheck; } else { - final String message = Objects.isNull(errorMessage) - ? "The input int [%d] is required to be in the range [%d, %d] boundaries included." - .formatted(toCheck, lowerBoundary, upperBoundary) - : errorMessage; - throw new IllegalArgumentException(message); + throw new IllegalArgumentException(errorMessage.formatted(toCheck, lowerBoundary, upperBoundary)); } } /** - * This method asserts a given long is a whole number. A long is whole - * if it is greater or equal to zero. + * This method asserts a given long is a whole number. + * A long is whole if it is greater or equal to zero. * * @param toCheck the long to check if it is a whole number * @return the number to check if it is whole number - * @throws IllegalArgumentException if the input number to check is not - * positive + * @throws IllegalArgumentException if the input number to check is not positive */ public static long requireWhole(final long toCheck) { - return requireWhole(toCheck, null); + return requireWhole(toCheck, DEFAULT_REQUIRE_WHOLE_MESSAGE); } /** - * This method asserts a given long is a whole number. A long is whole - * if it is greater or equal to zero. + * This method asserts a given long is a whole number. + * A long is whole if it is greater or equal to zero. * - * @param toCheck the long to check if it is a whole number - * @param errorMessage the error message to be used in the exception if the - * input long to check is not a whole number, if null, a - * default message will - * be used + * @param toCheck the long to check if it is a whole number + * @param errorMessage a formatted string with one decimal parameters for + * {@code toCheck}, must not be {@code null}.
+ * Example error message: {@value #DEFAULT_REQUIRE_WHOLE_MESSAGE} * @return the number to check if it is whole number - * @throws IllegalArgumentException if the input number to check is not - * positive + * @throws IllegalArgumentException if the input number to check is not positive + * @see java.util.Formatter for more information on error message formatting */ - public static long requireWhole(final long toCheck, final String errorMessage) { + public static long requireWhole(final long toCheck, @NonNull final String errorMessage) { if (toCheck >= 0) { return toCheck; } else { - final String message = Objects.isNull(errorMessage) - ? "The input integer [%d] is required be whole.".formatted(toCheck) - : errorMessage; - throw new IllegalArgumentException(message); + throw new IllegalArgumentException(errorMessage.formatted(toCheck)); } } @@ -272,30 +256,27 @@ public static long requireWhole(final long toCheck, final String errorMessage) { * @param toCheck the number to check if it is a power of two * @return the number to check if it is a power of two * @throws IllegalArgumentException if the input number to check is not a - * power of two + * power of two */ public static int requirePowerOfTwo(final int toCheck) { - return requirePowerOfTwo(toCheck, null); + return requirePowerOfTwo(toCheck, DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE); } /** * This method asserts a given integer is a power of two. * - * @param toCheck the number to check if it is a power of two - * @param errorMessage the error message to be used in the exception if the - * input integer to check is not a power of two, if null, a - * default message - * will be used + * @param toCheck the number to check if it is a power of two + * @param errorMessage a formatted string with one decimal parameter for + * {@code toCheck}, must not be {@code null}.
+ * Example error message: {@value #DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE} * @return the number to check if it is a power of two * @throws IllegalArgumentException if the input number to check is not a - * power of two + * power of two + * @see java.util.Formatter for more information on error message formatting */ - public static int requirePowerOfTwo(final int toCheck, final String errorMessage) { + public static int requirePowerOfTwo(final int toCheck, @NonNull final String errorMessage) { if (!MathUtilities.isPowerOfTwo(toCheck)) { - final String message = Objects.isNull(errorMessage) - ? "The input integer [%d] is required to be a power of two.".formatted(toCheck) - : errorMessage; - throw new IllegalArgumentException(message); + throw new IllegalArgumentException(errorMessage.formatted(toCheck)); } else { return toCheck; } diff --git a/common/src/test/java/com/hedera/block/common/utils/PreconditionsTest.java b/common/src/test/java/com/hedera/block/common/utils/PreconditionsTest.java index 769ed95c..de044a88 100644 --- a/common/src/test/java/com/hedera/block/common/utils/PreconditionsTest.java +++ b/common/src/test/java/com/hedera/block/common/utils/PreconditionsTest.java @@ -29,6 +29,17 @@ * Tests for {@link Preconditions} functionality. */ class PreconditionsTest { + private static final String DEFAULT_NOT_BLANK_MESSAGE = "The input String is required to be non-blank."; + private static final String DEFAULT_REQUIRE_POSITIVE_MESSAGE = "The input number [%d] is required to be positive."; + private static final String DEFAULT_GT_OR_EQ_MESSAGE = + "The input number [%d] is required to be greater or equal than [%d]."; + private static final String DEFAULT_REQUIRE_IN_RANGE_MESSAGE = + "The input number [%d] is required to be in the range [%d, %d] boundaries included."; + private static final String DEFAULT_REQUIRE_WHOLE_MESSAGE = + "The input number [%d] is required to be a whole number."; + private static final String DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE = + "The input number [%d] is required to be a power of two."; + /** * This test aims to verify that the * {@link Preconditions#requireNotBlank(String)} will return the input @@ -61,9 +72,11 @@ void testRequireNotBlankPass(final String toTest) { @ParameterizedTest @MethodSource("com.hedera.block.common.CommonsTestUtility#blankStrings") void testRequireNotBlankFail(final String toTest) { - assertThatIllegalArgumentException().isThrownBy(() -> Preconditions.requireNotBlank(toTest)); + assertThatIllegalArgumentException() + .isThrownBy(() -> Preconditions.requireNotBlank(toTest)) + .withMessage(DEFAULT_NOT_BLANK_MESSAGE); - final String testErrorMessage = "test error message"; + final String testErrorMessage = DEFAULT_NOT_BLANK_MESSAGE.concat(" custom test error message"); assertThatIllegalArgumentException() .isThrownBy(() -> Preconditions.requireNotBlank(toTest, testErrorMessage)) .withMessage(testErrorMessage); @@ -100,12 +113,15 @@ void testRequireWholePass(final int toTest) { @ParameterizedTest @MethodSource("com.hedera.block.common.CommonsTestUtility#negativeIntegers") void testRequireWholeFail(final int toTest) { - assertThatIllegalArgumentException().isThrownBy(() -> Preconditions.requireWhole(toTest)); + assertThatIllegalArgumentException() + .isThrownBy(() -> Preconditions.requireWhole(toTest)) + .withMessage(DEFAULT_REQUIRE_WHOLE_MESSAGE.formatted(toTest)); - final String testErrorMessage = "test error message"; + final String testMessage = DEFAULT_REQUIRE_WHOLE_MESSAGE.concat(" custom test error message"); + final String expectedTestMessage = testMessage.formatted(toTest); assertThatIllegalArgumentException() - .isThrownBy(() -> Preconditions.requireWhole(toTest, testErrorMessage)) - .withMessage(testErrorMessage); + .isThrownBy(() -> Preconditions.requireWhole(toTest, testMessage)) + .withMessage(expectedTestMessage); } /** @@ -138,12 +154,15 @@ void testRequireGreaterOrEqualPass(final long toTest, final long base) { @ParameterizedTest @MethodSource("com.hedera.block.common.CommonsTestUtility#invalidGreaterOrEqualValues") void testRequireGreaterOrEqualFail(final long toTest, final long base) { - assertThatIllegalArgumentException().isThrownBy(() -> Preconditions.requireGreaterOrEqual(toTest, base)); + assertThatIllegalArgumentException() + .isThrownBy(() -> Preconditions.requireGreaterOrEqual(toTest, base)) + .withMessage(DEFAULT_GT_OR_EQ_MESSAGE.formatted(toTest, base)); - final String testErrorMessage = "test error message"; + final String testMessage = DEFAULT_GT_OR_EQ_MESSAGE.concat(" custom test error message"); + final String expectedTestMessage = testMessage.formatted(toTest, base); assertThatIllegalArgumentException() - .isThrownBy(() -> Preconditions.requireGreaterOrEqual(toTest, base, testErrorMessage)) - .withMessage(testErrorMessage); + .isThrownBy(() -> Preconditions.requireGreaterOrEqual(toTest, base, testMessage)) + .withMessage(expectedTestMessage); } /** @@ -177,12 +196,15 @@ void testRequirePositivePass(final int toTest) { @ParameterizedTest @MethodSource("com.hedera.block.common.CommonsTestUtility#zeroAndNegativeIntegers") void testRequirePositiveFail(final int toTest) { - assertThatIllegalArgumentException().isThrownBy(() -> Preconditions.requirePositive(toTest)); + assertThatIllegalArgumentException() + .isThrownBy(() -> Preconditions.requirePositive(toTest)) + .withMessage(DEFAULT_REQUIRE_POSITIVE_MESSAGE.formatted(toTest)); - final String testErrorMessage = "test error message"; + final String testMessage = DEFAULT_REQUIRE_POSITIVE_MESSAGE.concat(" custom test error message"); + final String expectedTestMessage = testMessage.formatted(toTest); assertThatIllegalArgumentException() - .isThrownBy(() -> Preconditions.requirePositive(toTest, testErrorMessage)) - .withMessage(testErrorMessage); + .isThrownBy(() -> Preconditions.requirePositive(toTest, testMessage)) + .withMessage(expectedTestMessage); } /** @@ -215,12 +237,15 @@ void testRequirePositiveLongPass(final long toTest) { @ParameterizedTest @MethodSource("com.hedera.block.common.CommonsTestUtility#zeroAndNegativeIntegers") void testRequirePositiveLongFail(final long toTest) { - assertThatIllegalArgumentException().isThrownBy(() -> Preconditions.requirePositive(toTest)); + assertThatIllegalArgumentException() + .isThrownBy(() -> Preconditions.requirePositive(toTest)) + .withMessage(DEFAULT_REQUIRE_POSITIVE_MESSAGE.formatted(toTest)); - final String testErrorMessage = "test error message"; + final String testMessage = DEFAULT_REQUIRE_POSITIVE_MESSAGE.concat(" custom test error message"); + final String expectedTestMessage = testMessage.formatted(toTest); assertThatIllegalArgumentException() - .isThrownBy(() -> Preconditions.requirePositive(toTest, testErrorMessage)) - .withMessage(testErrorMessage); + .isThrownBy(() -> Preconditions.requirePositive(toTest, testMessage)) + .withMessage(expectedTestMessage); } /** @@ -258,12 +283,15 @@ void testRequirePowerOfTwoPass(final int toTest) { "com.hedera.block.common.CommonsTestUtility#negativePowerOfTwoIntegers" }) void testRequirePowerOfTwoFail(final int toTest) { - assertThatIllegalArgumentException().isThrownBy(() -> Preconditions.requirePowerOfTwo(toTest)); + assertThatIllegalArgumentException() + .isThrownBy(() -> Preconditions.requirePowerOfTwo(toTest)) + .withMessage(DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE.formatted(toTest)); - final String testErrorMessage = "test error message"; + final String testMessage = DEFAULT_REQUIRE_POWER_OF_TWO_MESSAGE.concat(" custom test error message"); + final String expectedTestMessage = testMessage.formatted(toTest); assertThatIllegalArgumentException() - .isThrownBy(() -> Preconditions.requirePowerOfTwo(toTest, testErrorMessage)) - .withMessage(testErrorMessage); + .isThrownBy(() -> Preconditions.requirePowerOfTwo(toTest, testMessage)) + .withMessage(expectedTestMessage); } /** @@ -304,12 +332,14 @@ void testRequireInRangePass(final int toTest, final int lowerBoundary, final int @MethodSource("invalidRequireInRangeValues") void testRequireInRangeFail(final int toTest, final int lowerBoundary, final int upperBoundary) { assertThatIllegalArgumentException() - .isThrownBy(() -> Preconditions.requireInRange(toTest, lowerBoundary, upperBoundary)); + .isThrownBy(() -> Preconditions.requireInRange(toTest, lowerBoundary, upperBoundary)) + .withMessage(DEFAULT_REQUIRE_IN_RANGE_MESSAGE.formatted(toTest, lowerBoundary, upperBoundary)); - final String testErrorMessage = "test error message"; + final String testMessage = DEFAULT_REQUIRE_IN_RANGE_MESSAGE.concat(" custom test error message"); + final String expectedTestMessage = testMessage.formatted(toTest, lowerBoundary, upperBoundary); assertThatIllegalArgumentException() - .isThrownBy(() -> Preconditions.requireInRange(toTest, lowerBoundary, upperBoundary, testErrorMessage)) - .withMessage(testErrorMessage); + .isThrownBy(() -> Preconditions.requireInRange(toTest, lowerBoundary, upperBoundary, testMessage)) + .withMessage(expectedTestMessage); } private static Stream validRequireInRangeValues() {