Merge pull request #15692 from hangga/securerandom-positive-long
BAEL-7491 - Generating Unique Positive Long using SecureRandom in Java
This commit is contained in:
		
						commit
						28c39d25a0
					
				| @ -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(); | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user