diff --git a/core-java-modules/core-java-numbers-7/src/test/java/com/baeldung/securerandompositivelong/SecureRandomPositiveLongUnitTest.java b/core-java-modules/core-java-numbers-7/src/test/java/com/baeldung/securerandompositivelong/SecureRandomPositiveLongUnitTest.java new file mode 100644 index 0000000000..7f7a778923 --- /dev/null +++ b/core-java-modules/core-java-numbers-7/src/test/java/com/baeldung/securerandompositivelong/SecureRandomPositiveLongUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.securerandompositivelong; + +import org.junit.jupiter.api.Test; + +import java.security.SecureRandom; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SecureRandomPositiveLongUnitTest { + + @Test + void whenGenerateRandomPositiveLong_thenGetPositiveValue() { + SecureRandom secureRandom = new SecureRandom(); + long randomPositiveLong = Math.abs(secureRandom.nextLong()); + + assertThat(randomPositiveLong).isNotNegative(); + } +}