style: format code with spotless
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 1m22s

This commit is contained in:
Jorge Bornhausen 2024-11-11 09:29:02 +01:00
parent e5e100076c
commit 40598dbe87
Signed by: jorge.bornhausen
SSH key fingerprint: SHA256:X2ootOwvCeP4FoNfmVUFIKIbhq95tAgnt7Oqg3x+lfs
17 changed files with 88 additions and 155 deletions

View file

@ -2,7 +2,6 @@ package ch.phoenixtechnologies.quarkus.commons.random;
import io.quarkus.arc.DefaultBean;
import jakarta.enterprise.context.ApplicationScoped;
import java.math.BigInteger;
import java.util.Random;

View file

@ -2,7 +2,6 @@ package ch.phoenixtechnologies.quarkus.commons.random;
import io.quarkus.arc.DefaultBean;
import jakarta.enterprise.context.ApplicationScoped;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
@ -19,6 +18,4 @@ class RandomProviderImpl implements RandomProvider {
throw new IllegalStateException("Unable to obtain strong SecureRandom instance", e);
}
}
}

View file

@ -1,15 +1,14 @@
package ch.phoenixtechnologies.quarkus.commons.random;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.mockito.InjectSpy;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import java.math.BigInteger;
import java.util.Random;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.Test;
@QuarkusTest
class RandomNumberGeneratorImplTest {
@ -26,9 +25,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateInt();
assertThat(actual)
.as("Generated int should match expected value")
.isEqualTo(-1305521323);
assertThat(actual).as("Generated int should match expected value").isEqualTo(-1305521323);
}
@Test
@ -37,9 +34,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateInt(40);
assertThat(actual)
.as("Generated int should match expected value")
.isEqualTo(26);
assertThat(actual).as("Generated int should match expected value").isEqualTo(26);
}
@Test
@ -48,21 +43,16 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateInt(1, 40);
assertThat(actual)
.as("Generated int should match expected value")
.isEqualTo(17);
assertThat(actual).as("Generated int should match expected value").isEqualTo(17);
}
@Test
void generateLong() {
when(provider.get()).thenReturn(getRandom());
var actual = generator.generateLong();
assertThat(actual)
.as("Generated long should match expected value")
.isEqualTo(-5607171386684657918L);
assertThat(actual).as("Generated long should match expected value").isEqualTo(-5607171386684657918L);
}
@Test
@ -71,9 +61,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateLong(40L);
assertThat(actual)
.as("Generated long should match expected value")
.isEqualTo(9L);
assertThat(actual).as("Generated long should match expected value").isEqualTo(9L);
}
@Test
@ -82,9 +70,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateLong(1L, 40L);
assertThat(actual)
.as("Generated long should match expected value")
.isEqualTo(23L);
assertThat(actual).as("Generated long should match expected value").isEqualTo(23L);
}
@Test
@ -93,9 +79,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateFloat();
assertThat(actual)
.as("Generated float should match expected value")
.isEqualTo(0.6960346f);
assertThat(actual).as("Generated float should match expected value").isEqualTo(0.6960346f);
}
@Test
@ -104,9 +88,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateFloat(0.99f);
assertThat(actual)
.as("Generated float should match expected value")
.isEqualTo(0.6890743f);
assertThat(actual).as("Generated float should match expected value").isEqualTo(0.6890743f);
}
@Test
@ -115,9 +97,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateFloat(0.01f, 0.99f);
assertThat(actual)
.as("Generated float should match expected value")
.isEqualTo(0.69211394f);
assertThat(actual).as("Generated float should match expected value").isEqualTo(0.69211394f);
}
@Test
@ -126,9 +106,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateDouble();
assertThat(actual)
.as("Generated double should match expected value")
.isEqualTo(0.6960346394874213d);
assertThat(actual).as("Generated double should match expected value").isEqualTo(0.6960346394874213d);
}
@Test
@ -137,9 +115,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateDouble(0.99d);
assertThat(actual)
.as("Generated double should match expected value")
.isEqualTo(0.6890742930925471d);
assertThat(actual).as("Generated double should match expected value").isEqualTo(0.6890742930925471d);
}
@Test
@ -148,9 +124,7 @@ class RandomNumberGeneratorImplTest {
var actual = generator.generateDouble(0.01d, 0.99d);
assertThat(actual)
.as("Generated double should match expected value")
.isEqualTo(0.6921139466976729d);
assertThat(actual).as("Generated double should match expected value").isEqualTo(0.6921139466976729d);
}
@Test
@ -176,5 +150,4 @@ class RandomNumberGeneratorImplTest {
private static Random getRandom() {
return new Random(24353L);
}
}
}

View file

@ -1,16 +1,15 @@
package ch.phoenixtechnologies.quarkus.commons.random;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.SecureRandom;
import java.security.Security;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.jupiter.api.Test;
@QuarkusTest
@SuppressWarnings("removal")
@ -47,16 +46,13 @@ class RandomProviderImplTest {
private static String getSecurityProperty() {
return AccessController.doPrivileged(
(PrivilegedAction<String>) () -> Security.getProperty(
SECURE_RANDOM_STRONG_ALGORITHMS));
(PrivilegedAction<String>) () -> Security.getProperty(SECURE_RANDOM_STRONG_ALGORITHMS));
}
private static void setSecurityProperty(String datum) {
AccessController.doPrivileged(
(PrivilegedAction<Void>) () -> {
Security.setProperty(
SECURE_RANDOM_STRONG_ALGORITHMS, datum);
return (Void) null;
});
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
Security.setProperty(SECURE_RANDOM_STRONG_ALGORITHMS, datum);
return (Void) null;
});
}
}
}