Class OptionalAssertions
- java.lang.Object
-
- com.github.robtimus.junit.support.OptionalAssertions
-
public final class OptionalAssertions extends Object
A collection of utility methods that support asserting conditions in tests forOptional,OptionalInt,OptionalLongandOptionalDouble.- Author:
- Rob Spoor
- Since:
- 2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertIsEmpty(Optional<?> optional)Asserts that the supplied optional is empty.static voidassertIsEmpty(Optional<?> optional, String message)Asserts that the supplied optional is empty.static voidassertIsEmpty(Optional<?> optional, Supplier<String> messageSupplier)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalDouble optional)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalDouble optional, String message)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalDouble optional, Supplier<String> messageSupplier)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalInt optional)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalInt optional, String message)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalInt optional, Supplier<String> messageSupplier)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalLong optional)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalLong optional, String message)Asserts that the supplied optional is empty.static voidassertIsEmpty(OptionalLong optional, Supplier<String> messageSupplier)Asserts that the supplied optional is empty.static <T> TassertIsPresent(Optional<T> optional)Asserts that the supplied optional is not empty.static <T> TassertIsPresent(Optional<T> optional, String message)Asserts that the supplied optional is not empty.static <T> TassertIsPresent(Optional<T> optional, Supplier<String> messageSupplier)Asserts that the supplied optional is not empty.static doubleassertIsPresent(OptionalDouble optional)Asserts that the supplied optional is not empty.static doubleassertIsPresent(OptionalDouble optional, String message)Asserts that the supplied optional is not empty.static doubleassertIsPresent(OptionalDouble optional, Supplier<String> messageSupplier)Asserts that the supplied optional is not empty.static intassertIsPresent(OptionalInt optional)Asserts that the supplied optional is not empty.static intassertIsPresent(OptionalInt optional, String message)Asserts that the supplied optional is not empty.static intassertIsPresent(OptionalInt optional, Supplier<String> messageSupplier)Asserts that the supplied optional is not empty.static longassertIsPresent(OptionalLong optional)Asserts that the supplied optional is not empty.static longassertIsPresent(OptionalLong optional, String message)Asserts that the supplied optional is not empty.static longassertIsPresent(OptionalLong optional, Supplier<String> messageSupplier)Asserts that the supplied optional is not empty.
-
-
-
Method Detail
-
assertIsPresent
public static <T> T assertIsPresent(Optional<T> optional)
Asserts that the supplied optional is not empty.- Type Parameters:
T- The optional value type.- Parameters:
optional- The optional to check.- Returns:
- The optional's value.
-
assertIsPresent
public static <T> T assertIsPresent(Optional<T> optional, String message)
Asserts that the supplied optional is not empty.- Type Parameters:
T- The optional value type.- Parameters:
optional- The optional to check.message- The failure message to fail with.- Returns:
- The optional's value.
-
assertIsPresent
public static <T> T assertIsPresent(Optional<T> optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is not empty.- Type Parameters:
T- The optional value type.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.- Returns:
- The optional's value.
-
assertIsPresent
public static int assertIsPresent(OptionalInt optional)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.- Returns:
- The optional's value.
-
assertIsPresent
public static int assertIsPresent(OptionalInt optional, String message)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.message- The failure message to fail with.- Returns:
- The optional's value.
-
assertIsPresent
public static int assertIsPresent(OptionalInt optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.- Returns:
- The optional's value.
-
assertIsPresent
public static long assertIsPresent(OptionalLong optional)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.- Returns:
- The optional's value.
-
assertIsPresent
public static long assertIsPresent(OptionalLong optional, String message)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.message- The failure message to fail with.- Returns:
- The optional's value.
-
assertIsPresent
public static long assertIsPresent(OptionalLong optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.- Returns:
- The optional's value.
-
assertIsPresent
public static double assertIsPresent(OptionalDouble optional)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.- Returns:
- The optional's value.
-
assertIsPresent
public static double assertIsPresent(OptionalDouble optional, String message)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.message- The failure message to fail with.- Returns:
- The optional's value.
-
assertIsPresent
public static double assertIsPresent(OptionalDouble optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is not empty.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.- Returns:
- The optional's value.
-
assertIsEmpty
public static void assertIsEmpty(Optional<?> optional)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.
-
assertIsEmpty
public static void assertIsEmpty(Optional<?> optional, String message)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.message- The failure message to fail with.
-
assertIsEmpty
public static void assertIsEmpty(Optional<?> optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.
-
assertIsEmpty
public static void assertIsEmpty(OptionalInt optional)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.
-
assertIsEmpty
public static void assertIsEmpty(OptionalInt optional, String message)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.message- The failure message to fail with.
-
assertIsEmpty
public static void assertIsEmpty(OptionalInt optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.
-
assertIsEmpty
public static void assertIsEmpty(OptionalLong optional)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.
-
assertIsEmpty
public static void assertIsEmpty(OptionalLong optional, String message)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.message- The failure message to fail with.
-
assertIsEmpty
public static void assertIsEmpty(OptionalLong optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.
-
assertIsEmpty
public static void assertIsEmpty(OptionalDouble optional)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.
-
assertIsEmpty
public static void assertIsEmpty(OptionalDouble optional, String message)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.message- The failure message to fail with.
-
assertIsEmpty
public static void assertIsEmpty(OptionalDouble optional, Supplier<String> messageSupplier)
Asserts that the supplied optional is empty.- Parameters:
optional- The optional to check.messageSupplier- The supplier for the failure message to fail with.
-
-