BAEL-3678 - Moving from java-numbers-2 to java-numbers-3 (#8521)
This commit is contained in:
parent
e10dc3cb9a
commit
4697561c51
@ -21,11 +21,6 @@
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>${jmh-generator.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>dsiutils</artifactId>
|
||||
<version>2.6.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -12,6 +12,14 @@
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>dsiutils</artifactId>
|
||||
<version>2.6.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>java-numbers-3</finalName>
|
||||
|
@ -70,12 +70,24 @@ public class RandomNumbersGenerator {
|
||||
return randomWithSplittableRandom;
|
||||
}
|
||||
|
||||
public IntStream generateRandomWithSplittableRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) {
|
||||
SplittableRandom splittableRandom = new SplittableRandom();
|
||||
IntStream limitedIntStreamWithinARangeWithSplittableRandom = splittableRandom.ints(streamSize, min, max);
|
||||
return limitedIntStreamWithinARangeWithSplittableRandom;
|
||||
}
|
||||
|
||||
public Integer generateRandomWithSecureRandom() {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
int randomWithSecureRandom = secureRandom.nextInt();
|
||||
return randomWithSecureRandom;
|
||||
}
|
||||
|
||||
public Integer generateRandomWithSecureRandomWithinARange(int min, int max) {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
int randomWithSecureRandomWithinARange = secureRandom.nextInt(max - min) + min;
|
||||
return randomWithSecureRandomWithinARange;
|
||||
}
|
||||
|
||||
public Integer generateRandomWithRandomDataGenerator(int min, int max) {
|
||||
RandomDataGenerator randomDataGenerator = new RandomDataGenerator();
|
||||
int randomWithRandomDataGenerator = randomDataGenerator.nextInt(min, max);
|
@ -11,6 +11,7 @@ public class RandomNumbersGeneratorUnitTest {
|
||||
|
||||
private static final int MIN_RANGE = 1;
|
||||
private static final int MAX_RANGE = 10;
|
||||
private static final int MIN_RANGE_NEGATIVE = -10;
|
||||
private static final int ITERATIONS = 50;
|
||||
private static final long STREAM_SIZE = 50;
|
||||
|
||||
@ -19,7 +20,7 @@ public class RandomNumbersGeneratorUnitTest {
|
||||
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||
for (int i = 0; i < ITERATIONS; i++) {
|
||||
int randomNumer = generator.generateRandomWithMathRandom(MIN_RANGE, MAX_RANGE);
|
||||
assertTrue(isInRange(randomNumer, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
assertTrue(isInRange(randomNumer, MIN_RANGE, MAX_RANGE));
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,10 +98,17 @@ public class RandomNumbersGeneratorUnitTest {
|
||||
public void whenGenerateRandomWithSplittableRandom_returnsSuccessfully() {
|
||||
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||
for (int i = 0; i < ITERATIONS; i++) {
|
||||
int randomNumber = generator.generateRandomWithSplittableRandom(MIN_RANGE, MAX_RANGE);
|
||||
assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE));
|
||||
int randomNumber = generator.generateRandomWithSplittableRandom(MIN_RANGE_NEGATIVE, MAX_RANGE);
|
||||
assertTrue(isInRange(randomNumber, MIN_RANGE_NEGATIVE, MAX_RANGE));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGenerateRandomWithSplittableRandomLimitedIntStreamWithinARange_returnsSuccessfully() {
|
||||
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||
generator.generateRandomWithSplittableRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE)
|
||||
.forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGenerateRandomWithSecureRandom_returnsSuccessfully() {
|
||||
@ -110,6 +118,15 @@ public class RandomNumbersGeneratorUnitTest {
|
||||
assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGenerateRandomWithSecureRandomWithinARange_returnsSuccessfully() {
|
||||
RandomNumbersGenerator generator = new RandomNumbersGenerator();
|
||||
for (int i = 0; i < ITERATIONS; i++) {
|
||||
int randomNumber = generator.generateRandomWithSecureRandomWithinARange(MIN_RANGE, MAX_RANGE);
|
||||
assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGenerateRandomWithRandomDataGenerator_returnsSuccessfully() {
|
Loading…
x
Reference in New Issue
Block a user