1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  package org.basepom.mojo.propertyhelper;
15  
16  import static org.assertj.core.api.Assertions.assertThat;
17  import static org.junit.jupiter.api.Assertions.assertNotNull;
18  import static org.junit.jupiter.api.Assertions.assertNotSame;
19  
20  import java.util.UUID;
21  
22  import org.junit.jupiter.api.Test;
23  
24  public class RandomUtilTest {
25  
26      @Test
27      public void testCreateRandomFromSeedString() {
28          String seedString = UUID.randomUUID().toString();
29  
30          var secureRandom1 = RandomUtil.createRandomFromSeed(seedString);
31          var secureRandom2 = RandomUtil.createRandomFromSeed(seedString);
32  
33          assertNotNull(secureRandom1);
34          assertNotNull(secureRandom2);
35  
36          
37          assertNotSame(secureRandom1, secureRandom2);
38  
39          long value1 = secureRandom1.nextLong();
40          long value2 = secureRandom2.nextLong();
41          assertThat(value1).isEqualTo(value2);
42      }
43  
44      
45  
46  
47  
48  
49      @Test
50      public void testCreateRandomFromNull() {
51          var secureRandom1 = RandomUtil.createRandomFromSeed(null);
52          var secureRandom2 = RandomUtil.createRandomFromSeed(null);
53  
54          assertNotNull(secureRandom1);
55          assertNotNull(secureRandom2);
56  
57          
58          assertNotSame(secureRandom1, secureRandom2);
59  
60          assertThat(secureRandom1.nextLong()).isNotEqualTo(secureRandom2.nextLong());
61      }
62  }