diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 35f7eef1a..e5bc795a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,12 +7,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source code - uses: actions/checkout@v1 + uses: actions/checkout@v6.0.2 with: ref: master - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v5.2.0 with: - java-version: 11 + distribution: 'temurin' + java-version: '17' - name: Build with Maven - run: mvn clean package + run: mvn clean package --batch-mode diff --git a/LICENSE.txt b/LICENSE.txt index 6b96290ce..aa1602581 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) +Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 8e026c4d7..b930afa6a 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,13 @@
Easy Random
- The simple, stupid random Java™ beans generator + The simple, stupid random Java™ objects generator
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](http://opensource.org/licenses/MIT) [![Build Status](https://github.com/j-easy/easy-random/workflows/Java%20CI/badge.svg)](https://github.com/j-easy/easy-random/actions) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.jeasy/easy-random-core/badge.svg?style=flat)](https://repo1.maven.org/maven2/org/jeasy/easy-random-core/5.0.0/) -[![Javadocs](http://www.javadoc.io/badge/org.jeasy/easy-random-core.svg)](http://www.javadoc.io/doc/org.jeasy/easy-random-core) [![Project status](https://img.shields.io/badge/Project%20status-Maintenance-orange.svg)](https://img.shields.io/badge/Project%20status-Maintenance-orange.svg)
@@ -31,7 +29,7 @@ for now. Please consider upgrading to one of these versions at your earliest con # What is Easy Random ? -Easy Random is a library that generates random Java beans. You can think of it as an [ObjectMother](https://martinfowler.com/bliki/ObjectMother.html) for the JVM. Let's say you have a class `Person` and you want to generate a random instance of it, here we go: +Easy Random is a library that generates random Java objects. You can think of it as an [ObjectMother](https://martinfowler.com/bliki/ObjectMother.html) for the JVM. Let's say you have a class `Person` and you want to generate a random instance of it, here we go: ```java EasyRandom easyRandom = new EasyRandom(); @@ -108,7 +106,7 @@ Address address = new Address(street, "123456", "London", "United Kingdom"); Person person = new Person("Foo", "Bar", "foo.bar@gmail.com", Gender.MALE, address); ``` -And if these classes do not provide constructors with parameters (may be some legacy beans you can't change), you would write: +And if these classes do not provide constructors with parameters (may be some legacy types you can't change), you would write: ```java Street street = new Street(); diff --git a/easy-random-bean-validation/pom.xml b/easy-random-bean-validation/pom.xml deleted file mode 100644 index 18ccdd821..000000000 --- a/easy-random-bean-validation/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - easy-random - org.jeasy - 5.0.1-SNAPSHOT - - 4.0.0 - - Easy Random Bean Validation - easy-random-bean-validation - Easy Random module for Bean Validation API support - https://github.com/j-easy/easy-random - - - git@github.com:j-easy/easy-random.git - scm:git:git@github.com:j-easy/easy-random.git - scm:git:git@github.com:j-easy/easy-random.git - HEAD - - - - Github Actions - https://github.com/j-easy/easy-random/actions - - - - GitHub - https://github.com/j-easy/easy-random - - - - - MIT License - http://opensource.org/licenses/mit-license.php - - - - - - benas - Mahmoud Ben Hassine - http://benas.github.io - mahmoud.benhassine@icloud.com - - Lead developer - - - - - - - org.jeasy - easy-random-randomizers - - - javax.validation - validation-api - - - org.hibernate - hibernate-validator - test - - - org.glassfish - javax.el - test - - - org.junit.jupiter - junit-jupiter - test - - - org.assertj - assertj-core - test - - - - diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AbstractNumberBaseAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AbstractNumberBaseAnnotationHandler.java deleted file mode 100644 index f3a2fe4de..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AbstractNumberBaseAnnotationHandler.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.range.*; -import org.jeasy.random.randomizers.text.StringDelegatingRandomizer; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Random; - -/** - * @author dadiyang - * @since 4.3 - */ -public abstract class AbstractNumberBaseAnnotationHandler implements BeanValidationAnnotationHandler { - private final Random random; - - AbstractNumberBaseAnnotationHandler(long seed) { - random = new Random(seed); - } - - protected Randomizer getRandomizer(Class fieldType, BigDecimal minValue, BigDecimal maxValue) { - if (fieldType.equals(Byte.TYPE) || fieldType.equals(Byte.class)) { - return new ByteRangeRandomizer( - minValue == null ? null : minValue.byteValue(), - maxValue == null ? null : maxValue.byteValue(), - random.nextLong() - ); - } - if (fieldType.equals(Short.TYPE) || fieldType.equals(Short.class)) { - return new ShortRangeRandomizer( - minValue == null ? null : minValue.shortValue(), - maxValue == null ? null : maxValue.shortValue(), - random.nextLong() - ); - } - if (fieldType.equals(Integer.TYPE) || fieldType.equals(Integer.class)) { - return new IntegerRangeRandomizer( - minValue == null ? null : minValue.intValue(), - maxValue == null ? null : maxValue.intValue(), - random.nextLong() - ); - } - if (fieldType.equals(Long.TYPE) || fieldType.equals(Long.class)) { - return new LongRangeRandomizer( - minValue == null ? null : minValue.longValue(), - maxValue == null ? null : maxValue.longValue(), - random.nextLong() - ); - } - if (fieldType.equals(BigInteger.class)) { - return new BigIntegerRangeRandomizer( - minValue == null ? null : minValue.intValue(), - maxValue == null ? null : maxValue.intValue(), - random.nextLong() - ); - } - if (fieldType.equals(BigDecimal.class)) { - return new BigDecimalRangeRandomizer( - minValue == null ? null : minValue.doubleValue(), - maxValue == null ? null : maxValue.doubleValue(), - random.nextLong() - ); - } - if (fieldType.equals(String.class)) { - BigDecimalRangeRandomizer delegate = new BigDecimalRangeRandomizer( - minValue == null ? null : minValue.doubleValue(), - maxValue == null ? null : maxValue.doubleValue(), - random.nextLong() - ); - return new StringDelegatingRandomizer(delegate); - } - return null; - } - -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertFalseAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertFalseAnnotationHandler.java deleted file mode 100644 index a4ca59052..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertFalseAnnotationHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.misc.ConstantRandomizer; - -import java.lang.reflect.Field; - -class AssertFalseAnnotationHandler implements BeanValidationAnnotationHandler { - - public Randomizer getRandomizer(Field field) { - return new ConstantRandomizer<>(false); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertTrueAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertTrueAnnotationHandler.java deleted file mode 100644 index bb7280ed1..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/AssertTrueAnnotationHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.misc.ConstantRandomizer; - -import java.lang.reflect.Field; - -class AssertTrueAnnotationHandler implements BeanValidationAnnotationHandler { - - public Randomizer getRandomizer(Field field) { - return new ConstantRandomizer<>(true); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationAnnotationHandler.java deleted file mode 100644 index 44310425c..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationAnnotationHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - - -import org.jeasy.random.api.Randomizer; - -import java.lang.reflect.Field; - -interface BeanValidationAnnotationHandler { - - Randomizer getRandomizer(Field field); - -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationRandomizerRegistry.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationRandomizerRegistry.java deleted file mode 100644 index 90772fdc2..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/BeanValidationRandomizerRegistry.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.annotation.Priority; -import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.api.RandomizerRegistry; -import org.jeasy.random.util.ReflectionUtils; - -import javax.validation.constraints.*; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -/** - * A registry of randomizers to support fields annotated with the JSR 349 annotations. - * - * @author Rémi Alvergnat (toilal.dev@gmail.com) - */ -@Priority(-2) -public class BeanValidationRandomizerRegistry implements RandomizerRegistry { - - protected Map, BeanValidationAnnotationHandler> annotationHandlers = new HashMap<>(); - - @Override - public void init(EasyRandomParameters parameters) { - long seed = parameters.getSeed(); - annotationHandlers.put(AssertFalse.class, new AssertFalseAnnotationHandler()); - annotationHandlers.put(AssertTrue.class, new AssertTrueAnnotationHandler()); - annotationHandlers.put(Null.class, new NullAnnotationHandler()); - annotationHandlers.put(Future.class, new FutureAnnotationHandler(parameters)); - annotationHandlers.put(FutureOrPresent.class, new FutureOrPresentAnnotationHandler(parameters)); - annotationHandlers.put(Past.class, new PastAnnotationHandler(parameters)); - annotationHandlers.put(PastOrPresent.class, new PastOrPresentAnnotationHandler(parameters)); - annotationHandlers.put(Min.class, new MinMaxAnnotationHandler(seed)); - annotationHandlers.put(Max.class, new MinMaxAnnotationHandler(seed)); - annotationHandlers.put(DecimalMin.class, new DecimalMinMaxAnnotationHandler(seed)); - annotationHandlers.put(DecimalMax.class, new DecimalMinMaxAnnotationHandler(seed)); - annotationHandlers.put(Pattern.class, new PatternAnnotationHandler(seed)); - annotationHandlers.put(Size.class, new SizeAnnotationHandler(parameters)); - annotationHandlers.put(Positive.class, new PositiveAnnotationHandler(seed)); - annotationHandlers.put(PositiveOrZero.class, new PositiveOrZeroAnnotationHandler(seed)); - annotationHandlers.put(Negative.class, new NegativeAnnotationHandler(seed)); - annotationHandlers.put(NegativeOrZero.class, new NegativeOrZeroAnnotationHandler(seed)); - annotationHandlers.put(NotBlank.class, new NotBlankAnnotationHandler(seed)); - annotationHandlers.put(Email.class, new EmailAnnotationHandler(seed)); - } - - @Override - public Randomizer getRandomizer(final Field field) { - - for (Map.Entry, BeanValidationAnnotationHandler> entry : annotationHandlers.entrySet()) { - Class annotation = entry.getKey(); - BeanValidationAnnotationHandler annotationHandler = entry.getValue(); - if (ReflectionUtils - .isAnnotationPresent(field, annotation) && annotationHandler != null) { - return annotationHandler.getRandomizer(field); - } - } - return null; - } - - @Override - public Randomizer getRandomizer(Class fieldType) { - return null; - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/DecimalMinMaxAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/DecimalMinMaxAnnotationHandler.java deleted file mode 100644 index 20dc10da1..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/DecimalMinMaxAnnotationHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.util.ReflectionUtils; - -import javax.validation.constraints.DecimalMax; -import javax.validation.constraints.DecimalMin; -import java.lang.reflect.Field; -import java.math.BigDecimal; - -class DecimalMinMaxAnnotationHandler extends AbstractNumberBaseAnnotationHandler { - - DecimalMinMaxAnnotationHandler(long seed) { - super(seed); - } - - @Override - public Randomizer getRandomizer(Field field) { - Class fieldType = field.getType(); - DecimalMax decimalMaxAnnotation = ReflectionUtils - .getAnnotation(field, DecimalMax.class); - DecimalMin decimalMinAnnotation = ReflectionUtils - .getAnnotation(field, DecimalMin.class); - - BigDecimal maxValue = null; - BigDecimal minValue = null; - - if (decimalMaxAnnotation != null) { - maxValue = new BigDecimal(decimalMaxAnnotation.value()); - } - - if (decimalMinAnnotation != null) { - minValue = new BigDecimal(decimalMinAnnotation.value()); - } - return getRandomizer(fieldType, minValue, maxValue); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureAnnotationHandler.java deleted file mode 100644 index 18238f911..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureAnnotationHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import java.lang.reflect.Field; -import java.time.LocalDate; -import java.time.temporal.ChronoUnit; - -import org.jeasy.random.EasyRandom; -import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.api.Randomizer; - -class FutureAnnotationHandler implements BeanValidationAnnotationHandler { - - private EasyRandom easyRandom; - private EasyRandomParameters parameters; - - FutureAnnotationHandler(EasyRandomParameters parameters) { - this.parameters = parameters.copy(); - } - - @Override - public Randomizer getRandomizer(Field field) { - if (easyRandom == null) { - LocalDate now = LocalDate.now(); - parameters.setDateRange(new EasyRandomParameters.Range<>( - now.plus(1, ChronoUnit.DAYS), - now.plusYears(EasyRandomParameters.DEFAULT_DATE_RANGE) - )); - easyRandom = new EasyRandom(parameters); - } - return () -> easyRandom.nextObject(field.getType()); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureOrPresentAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureOrPresentAnnotationHandler.java deleted file mode 100644 index f7c46dceb..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/FutureOrPresentAnnotationHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.EasyRandom; -import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.api.Randomizer; - -import java.lang.reflect.Field; -import java.time.LocalDate; - -class FutureOrPresentAnnotationHandler implements BeanValidationAnnotationHandler { - - private EasyRandom easyRandom; - private EasyRandomParameters parameters; - - FutureOrPresentAnnotationHandler(EasyRandomParameters parameters) { - this.parameters = parameters.copy(); - } - - @Override - public Randomizer getRandomizer(Field field) { - if (easyRandom == null) { - LocalDate now = LocalDate.now(); - parameters.setDateRange(new EasyRandomParameters.Range<>( - now, now.plusYears(EasyRandomParameters.DEFAULT_DATE_RANGE)) - ); - easyRandom = new EasyRandom(parameters); - } - return () -> easyRandom.nextObject(field.getType()); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/MinMaxAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/MinMaxAnnotationHandler.java deleted file mode 100644 index f94818045..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/MinMaxAnnotationHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.util.ReflectionUtils; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import java.lang.reflect.Field; -import java.math.BigDecimal; - -class MinMaxAnnotationHandler extends AbstractNumberBaseAnnotationHandler { - - MinMaxAnnotationHandler(long seed) { - super(seed); - } - - @Override - public Randomizer getRandomizer(Field field) { - Class fieldType = field.getType(); - Max maxAnnotation = ReflectionUtils - .getAnnotation(field, Max.class); - Min minAnnotation = ReflectionUtils - .getAnnotation(field, Min.class); - BigDecimal maxValue = null; - BigDecimal minValue = null; - - if (maxAnnotation != null) { - maxValue = new BigDecimal(maxAnnotation.value()); - } - - if (minAnnotation != null) { - minValue = new BigDecimal(minAnnotation.value()); - } - return getRandomizer(fieldType, minValue, maxValue); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeAnnotationHandler.java deleted file mode 100644 index 962f91164..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeAnnotationHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; - -import java.lang.reflect.Field; -import java.math.BigDecimal; - -class NegativeAnnotationHandler extends AbstractNumberBaseAnnotationHandler { - - NegativeAnnotationHandler(final long seed) { - super(seed); - } - - @Override - public Randomizer getRandomizer(Field field) { - return getRandomizer(field.getType(), null, BigDecimal.ZERO); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeOrZeroAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeOrZeroAnnotationHandler.java deleted file mode 100644 index 9024f85e0..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NegativeOrZeroAnnotationHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; - -import java.lang.reflect.Field; -import java.math.BigDecimal; - -class NegativeOrZeroAnnotationHandler extends AbstractNumberBaseAnnotationHandler { - NegativeOrZeroAnnotationHandler(final long seed) { - super(seed); - } - - @Override - public Randomizer getRandomizer(Field field) { - return getRandomizer(field.getType(), null, new BigDecimal("0.001")); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NullAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NullAnnotationHandler.java deleted file mode 100644 index 972495aa4..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NullAnnotationHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.misc.NullRandomizer; - -import java.lang.reflect.Field; - -class NullAnnotationHandler implements BeanValidationAnnotationHandler { - - @Override - public Randomizer getRandomizer(Field field) { - return new NullRandomizer(); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastAnnotationHandler.java deleted file mode 100644 index b95a22e4f..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastAnnotationHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import java.lang.reflect.Field; -import java.time.LocalDate; -import java.time.temporal.ChronoUnit; - -import org.jeasy.random.EasyRandom; -import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.api.Randomizer; - -class PastAnnotationHandler implements BeanValidationAnnotationHandler { - - private EasyRandom easyRandom; - private EasyRandomParameters parameters; - - PastAnnotationHandler(EasyRandomParameters parameters) { - this.parameters = parameters.copy(); - } - - @Override - public Randomizer getRandomizer(Field field) { - if (easyRandom == null) { - LocalDate now = LocalDate.now(); - parameters.setDateRange(new EasyRandomParameters.Range<>( - now.minusYears(EasyRandomParameters.DEFAULT_DATE_RANGE), - now.minus(1, ChronoUnit.DAYS) - )); - easyRandom = new EasyRandom(parameters); - } - return () -> easyRandom.nextObject(field.getType()); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastOrPresentAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastOrPresentAnnotationHandler.java deleted file mode 100644 index 2fa4387be..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PastOrPresentAnnotationHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.EasyRandom; -import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.api.Randomizer; - -import java.lang.reflect.Field; -import java.time.LocalDate; - -class PastOrPresentAnnotationHandler implements BeanValidationAnnotationHandler { - - private EasyRandom easyRandom; - private EasyRandomParameters parameters; - - PastOrPresentAnnotationHandler(EasyRandomParameters parameters) { - this.parameters = parameters.copy(); - } - - @Override - public Randomizer getRandomizer(Field field) { - if (easyRandom == null) { - LocalDate now = LocalDate.now(); - parameters.setDateRange(new EasyRandomParameters.Range<>( - now.minusYears(EasyRandomParameters.DEFAULT_DATE_RANGE), now)); - easyRandom = new EasyRandom(parameters); - } - return () -> easyRandom.nextObject(field.getType()); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PatternAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PatternAnnotationHandler.java deleted file mode 100644 index b59581cfa..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PatternAnnotationHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.RegularExpressionRandomizer; -import org.jeasy.random.util.ReflectionUtils; - -import javax.validation.constraints.Pattern; -import java.lang.reflect.Field; -import java.util.Random; - -class PatternAnnotationHandler implements BeanValidationAnnotationHandler { - - private final Random random; - - PatternAnnotationHandler(long seed) { - random = new Random(seed); - } - - @Override - public Randomizer getRandomizer(Field field) { - Class fieldType = field.getType(); - Pattern patternAnnotation = ReflectionUtils - .getAnnotation(field, Pattern.class); - - final String regex = patternAnnotation.regexp(); - if (fieldType.equals(String.class)) { - return new RegularExpressionRandomizer(regex, random.nextLong()); - } - return null; - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveOrZeroAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveOrZeroAnnotationHandler.java deleted file mode 100644 index c6837abfb..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveOrZeroAnnotationHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.api.Randomizer; - -import java.lang.reflect.Field; -import java.math.BigDecimal; - -class PositiveOrZeroAnnotationHandler extends AbstractNumberBaseAnnotationHandler { - - PositiveOrZeroAnnotationHandler(final long seed) { - super(seed); - } - - @Override - public Randomizer getRandomizer(Field field) { - return getRandomizer(field.getType(), BigDecimal.ZERO, null); - } -} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/SizeAnnotationHandler.java b/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/SizeAnnotationHandler.java deleted file mode 100644 index 27e908c68..000000000 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/SizeAnnotationHandler.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.EasyRandom; -import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.range.IntegerRangeRandomizer; -import org.jeasy.random.randomizers.text.StringRandomizer; -import org.jeasy.random.util.ReflectionUtils; -import org.objenesis.ObjenesisStd; - -import javax.validation.constraints.Size; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.EnumMap; -import java.util.Map; - -import static org.jeasy.random.util.ReflectionUtils.*; - -class SizeAnnotationHandler implements BeanValidationAnnotationHandler { - - private EasyRandom easyRandom; - private EasyRandomParameters parameters; - - SizeAnnotationHandler(EasyRandomParameters parameters) { - this.parameters = parameters.copy(); - } - - @Override - @SuppressWarnings({"unchecked"}) - public Randomizer getRandomizer(Field field) { - Class fieldType = field.getType(); - Size sizeAnnotation = ReflectionUtils - .getAnnotation(field, Size.class); - - final int min = sizeAnnotation.min(); - final int max = sizeAnnotation.max() == Integer.MAX_VALUE ? 255 : sizeAnnotation.max(); - if (easyRandom == null) { - easyRandom = new EasyRandom(parameters); - } - - if (fieldType.equals(String.class)) { - return new StringRandomizer(parameters.getCharset(), min, max, easyRandom.nextLong()); - } - - // FIXME: There should be away to reuse code from ArrayPopulator/CollectionPopulator/MapPopulator *without* making them public - - if (isArrayType(fieldType)) { - return (Randomizer) () -> { - int randomSize = new IntegerRangeRandomizer(min, max, parameters.getSeed()).getRandomValue(); - Object result = Array.newInstance(field.getType().getComponentType(), randomSize); - for (int i = 0; i < randomSize; i++) { - Object randomElement = easyRandom.nextObject(fieldType.getComponentType()); - Array.set(result, i, randomElement); - } - return result; - }; - } - - if (isCollectionType(fieldType)) { - return (Randomizer) () -> { - int randomSize = new IntegerRangeRandomizer(min, max, parameters.getSeed()).getRandomValue(); - Type fieldGenericType = field.getGenericType(); - Collection collection; - - if (isInterface(fieldType)) { - collection = getEmptyImplementationForCollectionInterface(fieldType); - } else { - collection = createEmptyCollectionForType(fieldType, randomSize); - } - if (isParameterizedType(fieldGenericType)) { // populate only parameterized types, raw types will be empty - ParameterizedType parameterizedType = (ParameterizedType) fieldGenericType; - Type type = parameterizedType.getActualTypeArguments()[0]; - if (isPopulatable(type)) { - for (int i = 0; i < randomSize; i++) { - Object item = easyRandom.nextObject((Class) type); - collection.add(item); - } - - } - } - return collection; - }; - } - if (isMapType(fieldType)) { - return (Randomizer) () -> { - int randomSize = new IntegerRangeRandomizer(min, max, parameters.getSeed()).getRandomValue(); - Type fieldGenericType = field.getGenericType(); - Map map; - - if (isInterface(fieldType)) { - map = (Map) getEmptyImplementationForMapInterface(fieldType); - } else { - try { - map = (Map) fieldType.getDeclaredConstructor().newInstance(); - } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { - if (fieldType.isAssignableFrom(EnumMap.class)) { - if (isParameterizedType(fieldGenericType)) { - Type type = ((ParameterizedType) fieldGenericType).getActualTypeArguments()[0]; - map = new EnumMap((Class)type); - } else { - return null; - } - } else { - map = (Map) new ObjenesisStd().newInstance(fieldType); - } - } - } - - if (isParameterizedType(fieldGenericType)) { // populate only parameterized types, raw types will be empty - ParameterizedType parameterizedType = (ParameterizedType) fieldGenericType; - Type keyType = parameterizedType.getActualTypeArguments()[0]; - Type valueType = parameterizedType.getActualTypeArguments()[1]; - if (isPopulatable(keyType) && isPopulatable(valueType)) { - for (int index = 0; index < randomSize; index++) { - Object randomKey = easyRandom.nextObject((Class) keyType); - Object randomValue = easyRandom.nextObject((Class) valueType); - if(randomKey != null) { - map.put(randomKey, randomValue); - } - } - } - } - return map; - }; - } - return null; - } -} diff --git a/easy-random-bean-validation/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry b/easy-random-bean-validation/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry deleted file mode 100644 index 2ba39df40..000000000 --- a/easy-random-bean-validation/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry +++ /dev/null @@ -1,25 +0,0 @@ -# -# The MIT License -# -# Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -org.jeasy.random.validation.BeanValidationRandomizerRegistry diff --git a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationAnnotatedBean.java b/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationAnnotatedBean.java deleted file mode 100644 index 4ceec9dd0..000000000 --- a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationAnnotatedBean.java +++ /dev/null @@ -1,422 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import javax.validation.constraints.*; -import java.math.BigDecimal; -import java.time.Instant; -import java.time.LocalDateTime; -import java.util.*; - -class BeanValidationAnnotatedBean { - - @AssertFalse - private boolean unsupported; - - @AssertTrue - private boolean active; - - @DecimalMax("30.00") - private BigDecimal maxDiscount; - - @DecimalMin("5.00") - private BigDecimal minDiscount; - - @DecimalMax("1.00") - @DecimalMin("0.01") - private BigDecimal discount; - - @Future - private Date eventDate; - - @Future - private LocalDateTime eventLocalDateTime; - - @FutureOrPresent - private Date futureOrPresent; - - @Past - private Date birthday; - - @Past - private LocalDateTime birthdayLocalDateTime; - - @Past - private Instant pastInstant; - - @PastOrPresent - private Date pastOrPresent; - - @Max(10) - private int maxQuantity; - - @Min(5) - private int minQuantity; - - @Positive - private int positive; - - @PositiveOrZero - private int positiveOrZero; - - @Negative - private int negative; - - @NegativeOrZero - private int negativeOrZero; - - @Positive - private Long positiveLong; - - @PositiveOrZero - private Long positiveOrZeroLong; - - @Negative - private Long negativeLong; - - @NegativeOrZero - private Long negativeOrZeroLong; - - @NotBlank - private String notBlank; - - @Email - private String email; - - @NotNull - private String username; - - @Null - private String unusedString; - - @Size(min = 2, max = 10) - private String briefMessage; - - @Size(min = 2, max = 10) - private Collection sizedCollection; - - @Size(min = 2, max = 10) - private List sizedList; - - @Size(min = 2, max = 10) - private List sizedListEmbeddedBean; - - @Size(min = 2, max = 10) - private Set sizedSet; - - @Size(min = 2, max = 10) - private Map sizedMap; - - @Size(min = 2, max = 10) - private String[] sizedArray; - - @Size(min = 2) - private String sizedString; - - @Pattern(regexp = "[a-z]{4}") - private String regexString; - - public BeanValidationAnnotatedBean() { - } - - public boolean isUnsupported() { - return this.unsupported; - } - - public boolean isActive() { - return this.active; - } - - public BigDecimal getMaxDiscount() { - return this.maxDiscount; - } - - public BigDecimal getMinDiscount() { - return this.minDiscount; - } - - public BigDecimal getDiscount() { - return this.discount; - } - - public Date getEventDate() { - return this.eventDate; - } - - public LocalDateTime getEventLocalDateTime() { - return this.eventLocalDateTime; - } - - public Date getFutureOrPresent() { - return this.futureOrPresent; - } - - public Date getBirthday() { - return this.birthday; - } - - public LocalDateTime getBirthdayLocalDateTime() { - return this.birthdayLocalDateTime; - } - - public Instant getPastInstant() { - return this.pastInstant; - } - - public Date getPastOrPresent() { - return this.pastOrPresent; - } - - public int getMaxQuantity() { - return this.maxQuantity; - } - - public int getMinQuantity() { - return this.minQuantity; - } - - public int getPositive() { - return this.positive; - } - - public int getPositiveOrZero() { - return this.positiveOrZero; - } - - public int getNegative() { - return this.negative; - } - - public int getNegativeOrZero() { - return this.negativeOrZero; - } - - public Long getPositiveLong() { - return positiveLong; - } - - public Long getPositiveOrZeroLong() { - return positiveOrZeroLong; - } - - public Long getNegativeLong() { - return negativeLong; - } - - public Long getNegativeOrZeroLong() { - return negativeOrZeroLong; - } - - public String getNotBlank() { - return this.notBlank; - } - - public String getEmail() { - return this.email; - } - - public String getUsername() { - return this.username; - } - - public String getUnusedString() { - return this.unusedString; - } - - public String getBriefMessage() { - return this.briefMessage; - } - - public Collection getSizedCollection() { - return this.sizedCollection; - } - - public List getSizedList() { - return this.sizedList; - } - - public Set getSizedSet() { - return this.sizedSet; - } - - public Map getSizedMap() { - return this.sizedMap; - } - - public String[] getSizedArray() { - return this.sizedArray; - } - - public String getSizedString() { - return this.sizedString; - } - - public List getSizedListEmbeddedBean() { - return sizedListEmbeddedBean; - } - - public String getRegexString() { - return this.regexString; - } - - public void setUnsupported(boolean unsupported) { - this.unsupported = unsupported; - } - - public void setActive(boolean active) { - this.active = active; - } - - public void setMaxDiscount(BigDecimal maxDiscount) { - this.maxDiscount = maxDiscount; - } - - public void setMinDiscount(BigDecimal minDiscount) { - this.minDiscount = minDiscount; - } - - public void setDiscount(BigDecimal discount) { - this.discount = discount; - } - - public void setEventDate(Date eventDate) { - this.eventDate = eventDate; - } - - public void setEventLocalDateTime(LocalDateTime eventLocalDateTime) { - this.eventLocalDateTime = eventLocalDateTime; - } - - public void setFutureOrPresent(Date futureOrPresent) { - this.futureOrPresent = futureOrPresent; - } - - public void setBirthday(Date birthday) { - this.birthday = birthday; - } - - public void setBirthdayLocalDateTime(LocalDateTime birthdayLocalDateTime) { - this.birthdayLocalDateTime = birthdayLocalDateTime; - } - - public void setPastInstant(Instant pastInstant) { - this.pastInstant = pastInstant; - } - - public void setPastOrPresent(Date pastOrPresent) { - this.pastOrPresent = pastOrPresent; - } - - public void setMaxQuantity(int maxQuantity) { - this.maxQuantity = maxQuantity; - } - - public void setMinQuantity(int minQuantity) { - this.minQuantity = minQuantity; - } - - public void setPositive(int positive) { - this.positive = positive; - } - - public void setPositiveOrZero(int positiveOrZero) { - this.positiveOrZero = positiveOrZero; - } - - public void setNegative(int negative) { - this.negative = negative; - } - - public void setNegativeOrZero(int negativeOrZero) { - this.negativeOrZero = negativeOrZero; - } - - public void setPositiveLong(Long positiveLong) { - this.positiveLong = positiveLong; - } - - public void setPositiveOrZeroLong(Long positiveOrZeroLong) { - this.positiveOrZeroLong = positiveOrZeroLong; - } - - public void setNegativeLong(Long negativeLong) { - this.negativeLong = negativeLong; - } - - public void setNegativeOrZeroLong(Long negativeOrZeroLong) { - this.negativeOrZeroLong = negativeOrZeroLong; - } - - public void setNotBlank(String notBlank) { - this.notBlank = notBlank; - } - - public void setEmail(String email) { - this.email = email; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setUnusedString(String unusedString) { - this.unusedString = unusedString; - } - - public void setBriefMessage(String briefMessage) { - this.briefMessage = briefMessage; - } - - public void setSizedCollection(Collection sizedCollection) { - this.sizedCollection = sizedCollection; - } - - public void setSizedList(List sizedList) { - this.sizedList = sizedList; - } - - public void setSizedSet(Set sizedSet) { - this.sizedSet = sizedSet; - } - - public void setSizedMap(Map sizedMap) { - this.sizedMap = sizedMap; - } - - public void setSizedArray(String[] sizedArray) { - this.sizedArray = sizedArray; - } - - public void setSizedString(String sizedString) { - this.sizedString = sizedString; - } - - public void setSizedListEmbeddedBean(List sizedListEmbeddedBean) { - this.sizedListEmbeddedBean = sizedListEmbeddedBean; - } - - public void setRegexString(String regexString) { - this.regexString = regexString; - } -} diff --git a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationMethodAnnotatedBean.java b/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationMethodAnnotatedBean.java deleted file mode 100644 index 917d3c653..000000000 --- a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationMethodAnnotatedBean.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import javax.validation.constraints.*; -import java.math.BigDecimal; -import java.time.Instant; -import java.time.LocalDateTime; -import java.util.*; - -class BeanValidationMethodAnnotatedBean { - - private boolean unsupported; - - private boolean active; - - private BigDecimal maxDiscount; - - private BigDecimal minDiscount; - - private BigDecimal discount; - - private int positive; - - private int positiveOrZero; - - private int negative; - - private int negativeOrZero; - - - private Long positiveLong; - - private Long positiveOrZeroLong; - - private Long negativeLong; - - private Long negativeOrZeroLong; - - private String notBlank; - - private String email; - - private Date eventDate; - private LocalDateTime eventLocalDateTime; - - private Date birthday; - private LocalDateTime birthdayLocalDateTime; - - private Date pastOrPresent; - private Date futureOrPresent; - - private Instant pastInstant; - - private int maxQuantity; - - private int minQuantity; - - private String username; - - private String unusedString; - - private String briefMessage; - - private Collection sizedCollection; - - private List sizedList; - - private List sizedListEmbeddedBean; - - private Set sizedSet; - - private Map sizedMap; - - private String[] sizedArray; - - private String sizedString; - - private String regexString; - - @AssertFalse - public boolean isUnsupported() { - return unsupported; - } - - public void setUnsupported(boolean unsupported) { - this.unsupported = unsupported; - } - - @AssertTrue - public boolean isActive() { - return active; - } - - public void setActive(boolean active) { - this.active = active; - } - - @DecimalMax("30.00") - public BigDecimal getMaxDiscount() { - return maxDiscount; - } - - public void setMaxDiscount(BigDecimal maxDiscount) { - this.maxDiscount = maxDiscount; - } - - @DecimalMin("5.00") - public BigDecimal getMinDiscount() { - return minDiscount; - } - - @DecimalMax("1.00") - @DecimalMin("0.01") - public BigDecimal getDiscount() { - return discount; - } - - public void setDiscount(BigDecimal discount) { - this.discount = discount; - } - - public void setMinDiscount(BigDecimal minDiscount) { - this.minDiscount = minDiscount; - } - - @Positive - public int getPositive() { - return positive; - } - - public void setPositive(int positive) { - this.positive = positive; - } - - - @PositiveOrZero - public int getPositiveOrZero() { - return positiveOrZero; - } - - public void setPositiveOrZero(int positiveOrZero) { - this.positiveOrZero = positiveOrZero; - } - - @Negative - public int getNegative() { - return negative; - } - - public void setNegative(int negative) { - this.negative = negative; - } - - @NegativeOrZero - public int getNegativeOrZero() { - return negativeOrZero; - } - - public void setNegativeOrZero(int negativeOrZero) { - this.negativeOrZero = negativeOrZero; - } - - @Positive - public Long getPositiveLong() { - return positiveLong; - } - - public void setPositiveLong(Long positiveLong) { - this.positiveLong = positiveLong; - } - - @PositiveOrZero - public Long getPositiveOrZeroLong() { - return positiveOrZeroLong; - } - - public void setPositiveOrZeroLong(Long positiveOrZeroLong) { - this.positiveOrZeroLong = positiveOrZeroLong; - } - - @Negative - public Long getNegativeLong() { - return negativeLong; - } - - public void setNegativeLong(Long negativeLong) { - this.negativeLong = negativeLong; - } - - @NegativeOrZero - public Long getNegativeOrZeroLong() { - return negativeOrZeroLong; - } - - public void setNegativeOrZeroLong(Long negativeOrZeroLong) { - this.negativeOrZeroLong = negativeOrZeroLong; - } - - @Future - public Date getEventDate() { - return eventDate; - } - - public void setEventDate(Date eventDate) { - this.eventDate = eventDate; - } - - @Future - public LocalDateTime getEventLocalDateTime() { - return eventLocalDateTime; - } - - public void setEventLocalDateTime(LocalDateTime eventLocalDateTime) { - this.eventLocalDateTime = eventLocalDateTime; - } - - @FutureOrPresent - public Date getFutureOrPresent() { - return futureOrPresent; - } - - public void setFutureOrPresent(Date futureOrPresent) { - this.futureOrPresent = futureOrPresent; - } - - @Past - public Date getBirthday() { - return birthday; - } - - public void setBirthday(Date birthday) { - this.birthday = birthday; - } - - @Past - public LocalDateTime getBirthdayLocalDateTime() { - return birthdayLocalDateTime; - } - - public void setBirthdayLocalDateTime(LocalDateTime birthdayLocalDateTime) { - this.birthdayLocalDateTime = birthdayLocalDateTime; - } - - @Past - public Instant getPastInstant() { - return pastInstant; - } - - public void setPastInstant(Instant pastInstant) { - this.pastInstant = pastInstant; - } - - @PastOrPresent - public Date getPastOrPresent() { - return pastOrPresent; - } - - public void setPastOrPresent(Date pastOrPresent) { - this.pastOrPresent = pastOrPresent; - } - - @Max(10) - public int getMaxQuantity() { - return maxQuantity; - } - - public void setMaxQuantity(int maxQuantity) { - this.maxQuantity = maxQuantity; - } - - @Min(5) - public int getMinQuantity() { - return minQuantity; - } - - public void setMinQuantity(int minQuantity) { - this.minQuantity = minQuantity; - } - - @NotNull - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - @Null - public String getUnusedString() { - return unusedString; - } - - public void setUnusedString(String unusedString) { - this.unusedString = unusedString; - } - - @Size(min=2, max=10) - public String getBriefMessage() { - return briefMessage; - } - - public void setBriefMessage(String briefMessage) { - this.briefMessage = briefMessage; - } - - @Pattern(regexp="[a-z]{4}") - public String getRegexString() { - return regexString; - } - - public void setRegexString(String regexString) { - this.regexString = regexString; - } - - @NotBlank - public String getNotBlank() { - return notBlank; - } - - public void setNotBlank(String notBlank) { - this.notBlank = notBlank; - } - - @Email - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Size(min=2, max=10) - public Collection getSizedCollection() { - return sizedCollection; - } - - public void setSizedCollection(Collection sizedCollection) { - this.sizedCollection = sizedCollection; - } - - @Size(min=2, max=10) - public List getSizedList() { - return sizedList; - } - - public void setSizedList(List sizedList) { - this.sizedList = sizedList; - } - - @Size(min = 2, max = 10) - public List getSizedListEmbeddedBean() { - return sizedListEmbeddedBean; - } - - public void setSizedListEmbeddedBean(List sizedListEmbeddedBean) { - this.sizedListEmbeddedBean = sizedListEmbeddedBean; - } - - @Size(min=2, max=10) - public Set getSizedSet() { - return sizedSet; - } - - public void setSizedSet(Set sizedSet) { - this.sizedSet = sizedSet; - } - - @Size(min=2, max=10) - public Map getSizedMap() { - return sizedMap; - } - - public void setSizedMap(Map sizedMap) { - this.sizedMap = sizedMap; - } - - @Size(min=2, max=10) - public String[] getSizedArray() { - return sizedArray; - } - - public void setSizedArray(String[] sizedArray) { - this.sizedArray = sizedArray; - } - - @Size(min=2) - public String getSizedString() { - return sizedString; - } - - public void setSizedString(String sizedString) { - this.sizedString = sizedString; - } - - @Override - public String toString() { - return "BeanValidationMethodAnnotatedBean{" + - "unsupported=" + unsupported + - ", active=" + active + - ", maxDiscount=" + maxDiscount + - ", minDiscount=" + minDiscount + - ", discount=" + discount + - ", positive=" + positive + - ", positiveOrZero=" + positiveOrZero + - ", negative=" + negative + - ", negativeOrZero=" + negativeOrZero + - ", notBlank='" + notBlank + '\'' + - ", email='" + email + '\'' + - ", eventDate=" + eventDate + - ", eventLocalDateTime=" + eventLocalDateTime + - ", birthday=" + birthday + - ", birthdayLocalDateTime=" + birthdayLocalDateTime + - ", pastOrPresent=" + pastOrPresent + - ", futureOrPresent=" + futureOrPresent + - ", maxQuantity=" + maxQuantity + - ", minQuantity=" + minQuantity + - ", username='" + username + '\'' + - ", unusedString='" + unusedString + '\'' + - ", briefMessage='" + briefMessage + '\'' + - ", sizedCollection=" + sizedCollection + - ", sizedList=" + sizedList + - ", sizedSet=" + sizedSet + - ", sizedMap=" + sizedMap + - ", sizedArray=" + Arrays.toString(sizedArray) + - ", sizedString=" + sizedString + - ", regexString='" + regexString + '\'' + - '}'; - } -} diff --git a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationTest.java b/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationTest.java deleted file mode 100644 index a3933ca6a..000000000 --- a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationTest.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import org.jeasy.random.EasyRandom; -import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.randomizers.range.BigDecimalRangeRandomizer; -import org.jeasy.random.randomizers.range.IntegerRangeRandomizer; -import org.jeasy.random.randomizers.registry.CustomRandomizerRegistry; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import javax.validation.ConstraintViolation; -import javax.validation.Valid; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import javax.validation.constraints.DecimalMax; -import javax.validation.constraints.DecimalMin; -import javax.validation.constraints.Digits; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; - -class BeanValidationTest { - - private EasyRandom easyRandom; - - @BeforeEach - void setUp() { - easyRandom = new EasyRandom(); - } - - @Test - void sizeConstraintShouldNotBePropagatedToEmbeddedBeans() { - - EasyRandomParameters parameters = new EasyRandomParameters() - .collectionSizeRange(11, 15) - .stringLengthRange(16, 20); - easyRandom = new EasyRandom(parameters); - BeanValidationAnnotatedBean bean = easyRandom.nextObject(BeanValidationAnnotatedBean.class); - - assertThat(bean.getSizedListEmbeddedBean().size()).isBetween(2, 10); // @Size constraint - assertThat(bean.getSizedListEmbeddedBean()).allSatisfy(embeddedBean -> { - assertThat(embeddedBean.getItems().size()).isBetween(11, 15); - assertThat(embeddedBean.getItems()).allSatisfy(stringItem -> assertThat(stringItem.length()).isBetween(16, 20)); - }); - } - - @Test - void sizeConstraintShouldTakePrecedenceOverCollectionSizeRangeInEmbeddedBeans() { - EasyRandomParameters parameters = new EasyRandomParameters() - .collectionSizeRange(11, 15) - .stringLengthRange(16, 20); - easyRandom = new EasyRandom(parameters); - BeanValidationAnnotatedBean bean = easyRandom.nextObject(BeanValidationAnnotatedBean.class); - - assertThat(bean.getSizedListEmbeddedBean().size()).isBetween(2, 10); // @Size constraint - assertThat(bean.getSizedListEmbeddedBean()).allSatisfy(embeddedBean -> { - assertThat(embeddedBean.getItems().size()).isBetween(11, 15); - assertThat(embeddedBean.getOtherItems().size()).isBetween(3, 5); // @Size(min = 3, max = 5) constraint should take precedence over collectionSizeRange(11, 15) - assertThat(embeddedBean.getItems()).allSatisfy(stringItem -> assertThat(stringItem.length()).isBetween(16, 20)); - assertThat(embeddedBean.getOtherItems()).allSatisfy(stringItem -> assertThat(stringItem.length()).isBetween(16, 20)); - }); - } - - @Test - void generatedValuesShouldBeValidAccordingToValidationConstraints() { - BeanValidationAnnotatedBean bean = easyRandom.nextObject(BeanValidationAnnotatedBean.class); - - assertThat(bean).isNotNull(); - - assertThat(bean.isUnsupported()).isFalse();// @AssertFalse boolean unsupported; - - assertThat(bean.isActive()).isTrue();// @AssertTrue boolean active; - - assertThat(bean.getUnusedString()).isNull();// @Null String unusedString; - - assertThat(bean.getUsername()).isNotNull();// @NotNull String username; - - assertThat(bean.getBirthday()).isInThePast();// @Past Date birthday; - - assertThat(bean.getBirthdayLocalDateTime()).isBefore(LocalDateTime.now());// @Past LocalDateTime birthdayLocalDateTime; - - assertThat(bean.getPastOrPresent()).isBeforeOrEqualTo(new Date());// @PastOrPresent Date pastOrPresent; - - assertThat(bean.getEventDate()).isInTheFuture();// @Future Date eventDate; - - assertThat(bean.getEventLocalDateTime()).isAfter(LocalDateTime.now());// @Future LocalDateTime eventLocalDateTime; - - assertThat(bean.getFutureOrPresent()).isAfterOrEqualTo(new Date());// @FutureOrPresent Date eventDate; - - assertThat(bean.getPositive()).isGreaterThan(0);// @Positive int positive; - - assertThat(bean.getPositiveOrZero()).isGreaterThanOrEqualTo(0);// @PositiveOrZero int positiveOrZero; - - assertThat(bean.getNegative()).isLessThan(0);// @Negative int negative; - - assertThat(bean.getNegativeOrZero()).isLessThanOrEqualTo(0);// @NegativeOrZero int negativeOrZero; - - assertThat(bean.getPositiveLong()).isGreaterThan(0);// @Positive Long positive; - - assertThat(bean.getPositiveOrZeroLong()).isGreaterThanOrEqualTo(0);// @PositiveOrZero Long positiveOrZero; - - assertThat(bean.getNegativeLong()).isLessThan(0);// @Negative Long negative; - - assertThat(bean.getNegativeOrZeroLong()).isLessThanOrEqualTo(0);// @NegativeOrZero Long negativeOrZero; - - assertThat(bean.getNotBlank()).isNotBlank(); // @NotBlank String notBlank; - - assertThat(bean.getEmail()).isNotBlank().contains(".", "@"); // @Email String email; - - assertThat(bean.getMaxQuantity()).isLessThanOrEqualTo(10);// @Max(10) int maxQuantity; - - assertThat(bean.getMinQuantity()).isGreaterThanOrEqualTo(5);// @Min(5) int minQuantity; - - assertThat(bean.getMaxDiscount()).isLessThanOrEqualTo(new BigDecimal("30.00"));// @DecimalMax("30.00") BigDecimal maxDiscount; - - assertThat(bean.getMinDiscount()).isGreaterThanOrEqualTo(new BigDecimal("5.00"));// @DecimalMin("5.00") BigDecimal minDiscount; - - assertThat(bean.getDiscount()).isLessThanOrEqualTo(new BigDecimal("1.00"));// @DecimalMax("1.00") BigDecimal discount; - assertThat(bean.getDiscount()).isGreaterThanOrEqualTo(new BigDecimal("0.01"));// @DecimalMin("0.01") BigDecimal discount; - - assertThat(bean.getMinQuantity()).isGreaterThanOrEqualTo(5);// @Min(5) int minQuantity; - - assertThat(bean.getBriefMessage().length()).isBetween(2, 10);// @Size(min=2, max=10) String briefMessage; - assertThat(bean.getSizedCollection().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedCollection; - assertThat(bean.getSizedList().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedList; - assertThat(bean.getSizedListEmbeddedBean().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedListEmbeddedBean; - assertThat(bean.getSizedSet().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedSet; - assertThat(bean.getSizedMap().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedMap; - assertThat(bean.getSizedArray().length).isBetween(2, 10);// @Size(min=2, max=10) String sizedArray; - assertThat(bean.getSizedString().length()).isBetween(2, 255);// @Size(min=2) String sizedString; - - assertThat(bean.getRegexString()).matches("[a-z]{4}"); - } - - @Test - void generatedValuesShouldBeValidAccordingToValidationConstraintsOnMethod() { - BeanValidationMethodAnnotatedBean bean = easyRandom.nextObject(BeanValidationMethodAnnotatedBean.class); - - assertThat(bean).isNotNull(); - - assertThat(bean.isUnsupported()).isFalse();// @AssertFalse boolean unsupported; - - assertThat(bean.isActive()).isTrue();// @AssertTrue boolean active; - - assertThat(bean.getUnusedString()).isNull();// @Null String unusedString; - - assertThat(bean.getUsername()).isNotNull();// @NotNull String username; - - assertThat(bean.getBirthday()).isInThePast();// @Past Date birthday; - - assertThat(bean.getBirthdayLocalDateTime()).isBefore(LocalDateTime.now());// @Past LocalDateTime birthdayLocalDateTime; - - assertThat(bean.getPastOrPresent()).isBeforeOrEqualTo(new Date());// @PastOrPresent Date pastOrPresent; - - assertThat(bean.getEventDate()).isInTheFuture();// @Future Date eventDate; - - assertThat(bean.getEventLocalDateTime()).isAfter(LocalDateTime.now());// @Future LocalDateTime eventLocalDateTime; - - assertThat(bean.getFutureOrPresent()).isAfterOrEqualTo(new Date());// @FutureOrPresent Date eventDate; - - assertThat(bean.getPositive()).isGreaterThan(0);// @Positive int positive; - - assertThat(bean.getPositiveOrZero()).isGreaterThanOrEqualTo(0);// @PositiveOrZero int positiveOrZero; - - assertThat(bean.getNegative()).isLessThan(0);// @Negative int negative; - - assertThat(bean.getNegativeOrZero()).isLessThanOrEqualTo(0);// @NegativeOrZero int negativeOrZero; - - assertThat(bean.getPositiveLong()).isGreaterThan(0);// @Positive Long positive; - - assertThat(bean.getPositiveOrZeroLong()).isGreaterThanOrEqualTo(0);// @PositiveOrZero Long positiveOrZero; - - assertThat(bean.getNegativeLong()).isLessThan(0);// @Negative Long negative; - - assertThat(bean.getNegativeOrZeroLong()).isLessThanOrEqualTo(0);// @NegativeOrZero Long negativeOrZero; - - assertThat(bean.getNotBlank()).isNotBlank(); // @NotBlank String notBlank; - - assertThat(bean.getEmail()).isNotBlank().contains(".", "@"); // @Email String email; - - assertThat(bean.getMaxQuantity()).isLessThanOrEqualTo(10);// @Max(10) int maxQuantity; - - assertThat(bean.getMinQuantity()).isGreaterThanOrEqualTo(5);// @Min(5) int minQuantity; - - assertThat(bean.getMaxDiscount()).isLessThanOrEqualTo(new BigDecimal("30.00"));// @DecimalMax("30.00") BigDecimal maxDiscount; - - assertThat(bean.getMinDiscount()).isGreaterThanOrEqualTo(new BigDecimal("5.00"));// @DecimalMin("5.00") BigDecimal minDiscount; - - assertThat(bean.getDiscount()).isLessThanOrEqualTo(new BigDecimal("1.00"));// @DecimalMax("1.00") BigDecimal discount; - assertThat(bean.getDiscount()).isGreaterThanOrEqualTo(new BigDecimal("0.01"));// @DecimalMin("0.01") BigDecimal discount; - - assertThat(bean.getMinQuantity()).isGreaterThanOrEqualTo(5);// @Min(5) int minQuantity; - - assertThat(bean.getBriefMessage().length()).isBetween(2, 10);// @Size(min=2, max=10) String briefMessage; - assertThat(bean.getSizedCollection().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedCollection; - assertThat(bean.getSizedList().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedList; - assertThat(bean.getSizedListEmbeddedBean().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedListEmbeddedBean; - assertThat(bean.getSizedSet().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedSet; - assertThat(bean.getSizedMap().size()).isBetween(2, 10);// @Size(min=2, max=10) String sizedMap; - assertThat(bean.getSizedArray().length).isBetween(2, 10);// @Size(min=2, max=10) String sizedArray; - assertThat(bean.getSizedString().length()).isBetween(2, 255);// @Size(min=2) String sizedString; - - assertThat(bean.getRegexString()).matches("[a-z]{4}"); - } - - @Test - void generatedValuesForBeanWithoutReadMethod() { - BeanValidationWithoutReadMethodBean bean = easyRandom.nextObject(BeanValidationWithoutReadMethodBean.class); - - assertThat(bean).hasNoNullFieldsOrProperties(); - } - - @Test - void shouldGenerateTheSameValueForTheSameSeed() { - EasyRandomParameters parameters = new EasyRandomParameters().seed(123L); - EasyRandom random = new EasyRandom(parameters); - - BeanValidationAnnotatedBean bean = random.nextObject(BeanValidationAnnotatedBean.class); - - assertThat(bean.getUsername()).isEqualTo("eOMtThyhVNLWUZNRcBaQKxI"); - // uses DateRange with now as end, so test is not repeatable - // assertThat(bean.getBirthday()).isEqualTo("2007-07-22T13:20:35.628"); // same for birthdayLocalDateTime - // uses DateRange with now as start, so test is not repeatable - // assertThat(bean.getEventDate()).isEqualTo("2017-07-22T13:20:35.628"); // same for eventLocalDateTime - assertThat(bean.getMaxQuantity()).isEqualTo(-2055951745); - assertThat(bean.getMinQuantity()).isEqualTo(91531906); - assertThat(bean.getMaxDiscount()).isEqualTo(new BigDecimal(1.2786858993971550457757757612853311002254486083984375)); - assertThat(bean.getMinDiscount()).isEqualTo(new BigDecimal(7662282876638370609146101740543801632384371011755725427644785896281033154465107481014236865090602870006608143292003443098160947481248487711461114361337135608579588927391230902925850523644737673724379044725003237691291118781433336121334962263919251188630152674215174880065707256545268445171714648124229156864D)); - assertThat(bean.getDiscount()).isEqualTo(new BigDecimal(0.182723708049134681008496272625052370131015777587890625)); - assertThat(bean.getMinQuantity()).isEqualTo(91531906); - assertThat(bean.getBriefMessage()).isEqualTo("tg"); - assertThat(bean.getRegexString()).isEqualTo("vuna"); - assertThat(bean.getPositive()).isEqualTo(91531902); - assertThat(bean.getPositiveOrZero()).isEqualTo(91531901); - assertThat(bean.getNegative()).isEqualTo(-2055951746); - assertThat(bean.getNegativeOrZero()).isEqualTo(-2055951746); - assertThat(bean.getEmail()).isEqualTo("celine.schoen@hotmail.com"); - assertThat(bean.getNotBlank()).isEqualTo("tg"); - } - - @Test - void generatedBeanShouldBeValidUsingBeanValidationAPI() { - BeanValidationAnnotatedBean bean = easyRandom.nextObject(BeanValidationAnnotatedBean.class); - - ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory(); - Validator validator = validatorFactory.getValidator(); - Set> violations = validator.validate(bean); - - assertThat(violations).isEmpty(); - } - - @Test - void customBeanValidationRegistryTest() { - // given - class Salary { - @Digits(integer = 2, fraction = 2) // OSS developer salary.. :-) - private BigDecimal amount; - } - - EasyRandomParameters parameters = new EasyRandomParameters() - .randomizerRegistry(new MyCustomBeanValidationRandomizerRegistry()); - EasyRandom easyRandom = new EasyRandom(parameters); - - // when - Salary salary = easyRandom.nextObject(Salary.class); - - // then - assertThat(salary).isNotNull(); - assertThat(salary.amount).isLessThanOrEqualTo(new BigDecimal("99.99")); - } - - @Test - void customRegistryTest() { - // given - class Amount { - @NotNull - @Digits(integer = 12, fraction = 3) - protected BigDecimal amount; - } - class DiscountEffect { - @Digits(integer = 6, fraction = 4) - protected BigDecimal percentage; - protected Amount amount; - @Digits(integer = 12, fraction = 3) - protected BigDecimal quantity; - @NotNull - @DecimalMax("65535") - @DecimalMin("1") - protected Integer size; - } - class Discount { - @NotNull - @Size(min = 1) - @Valid - protected List discountEffects; - } - - CustomRandomizerRegistry registry = new CustomRandomizerRegistry(); - registry.registerRandomizer(BigDecimal.class, new BigDecimalRangeRandomizer(Double.valueOf(5d), Double.valueOf(10d), Integer.valueOf(3))); - registry.registerRandomizer(Integer.class, new IntegerRangeRandomizer(5, 10)); - EasyRandomParameters parameters = new EasyRandomParameters() - .randomizerRegistry(registry); - EasyRandom easyRandom = new EasyRandom(parameters); - - // when - Discount discount = easyRandom.nextObject(Discount.class); - - // then - assertThat(discount.discountEffects) - .isNotEmpty() - .allSatisfy(discountEffect -> { - assertThat(discountEffect).isNotNull(); - assertThat(discountEffect.percentage).isBetween(new BigDecimal("5.000"), new BigDecimal("10.000")); - assertThat(discountEffect.quantity).isBetween(new BigDecimal("5.000"), new BigDecimal("10.000")); - assertThat(discountEffect.amount.amount).isBetween(new BigDecimal("5.000"), new BigDecimal("10.000")); - assertThat(discountEffect.size).isBetween(5, 10); - }); - } - -} diff --git a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/MyCustomBeanValidationRandomizerRegistry.java b/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/MyCustomBeanValidationRandomizerRegistry.java deleted file mode 100644 index 5f00b0d99..000000000 --- a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/MyCustomBeanValidationRandomizerRegistry.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import javax.validation.constraints.Digits; - -import org.jeasy.random.EasyRandomParameters; - -public class MyCustomBeanValidationRandomizerRegistry extends BeanValidationRandomizerRegistry { - - @Override - public void init(EasyRandomParameters parameters) { - super.init(parameters); - annotationHandlers.put(Digits.class, new MyCustomDigitsAnnotationHandler()); - } -} diff --git a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/MyCustomDigitsAnnotationHandler.java b/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/MyCustomDigitsAnnotationHandler.java deleted file mode 100644 index 6c1c7736a..000000000 --- a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/MyCustomDigitsAnnotationHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.validation; - -import java.lang.reflect.Field; - -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.number.BigDecimalRandomizer; - -public class MyCustomDigitsAnnotationHandler implements BeanValidationAnnotationHandler { - - @Override - public Randomizer getRandomizer(Field field) { - // `@Digits` is applicable to several types (see its javadoc) - // for this test, just assuming the field is a BigDecimal - return new BigDecimalRandomizer(Integer.valueOf(2)); - } - -} diff --git a/easy-random-core/pom.xml b/easy-random-core/pom.xml deleted file mode 100644 index e1de3fcfb..000000000 --- a/easy-random-core/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - easy-random - org.jeasy - 5.0.1-SNAPSHOT - - 4.0.0 - - Easy Random Core - easy-random-core - Easy Random core implementation - https://github.com/j-easy/easy-random - - - git@github.com:j-easy/easy-random.git - scm:git:git@github.com:j-easy/easy-random.git - scm:git:git@github.com:j-easy/easy-random.git - HEAD - - - - Github Actions - https://github.com/j-easy/easy-random/actions - - - - GitHub - https://github.com/j-easy/easy-random/issues - - - - - MIT License - http://opensource.org/licenses/mit-license.php - - - - - - benas - Mahmoud Ben Hassine - http://benas.github.io - mahmoud.benhassine@icloud.com - - Lead developer - - - - - - - org.objenesis - objenesis - - - io.github.classgraph - classgraph - - - org.junit.jupiter - junit-jupiter - test - - - org.assertj - assertj-core - test - - - org.mockito - mockito-core - test - - - org.mockito - mockito-junit-jupiter - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.plugins - maven-release-plugin - - - - - diff --git a/easy-random-randomizers/pom.xml b/easy-random-randomizers/pom.xml deleted file mode 100644 index 9ec895546..000000000 --- a/easy-random-randomizers/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - easy-random - org.jeasy - 5.0.1-SNAPSHOT - - 4.0.0 - - Easy Random Randomizers - easy-random-randomizers - Easy Random built-in randomizers - https://github.com/j-easy/easy-random - - - git@github.com:j-easy/easy-random.git - scm:git:git@github.com:j-easy/easy-random.git - scm:git:git@github.com:j-easy/easy-random.git - HEAD - - - - Github Actions - https://github.com/j-easy/easy-random/actions - - - - GitHub - https://github.com/j-easy/easy-random/issues - - - - - MIT License - http://opensource.org/licenses/mit-license.php - - - - - - benas - Mahmoud Ben Hassine - http://benas.github.io - mahmoud.benhassine@icloud.com - - Lead developer - - - - - - - org.jeasy - easy-random-core - - - com.github.javafaker - javafaker - - - org.junit.jupiter - junit-jupiter - test - - - org.assertj - assertj-core - test - - - - diff --git a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java b/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java deleted file mode 100644 index a9a1d73a8..000000000 --- a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.jeasy.random.randomizers; - -import java.util.Locale; - -import org.jeasy.random.api.Randomizer; - -class AbstractRandomizerTest { - - static final long SEED = 123L; - static final Locale LOCALE = Locale.FRANCE; - - Randomizer randomizer; - -} diff --git a/pom.xml b/pom.xml index 2d433e6a0..470575cdd 100644 --- a/pom.xml +++ b/pom.xml @@ -10,36 +10,33 @@ org.jeasy easy-random - 5.0.1-SNAPSHOT - pom + 6.0.0-SNAPSHOT Easy Random - Easy Random is a library to generate random Java beans + Easy Random is a library to generate random Java objects https://github.com/j-easy/easy-random UTF-8 - 11 - 5.7.0 - 1.0.2 - 3.18.0 - 2.0.1.Final - 3.1 - 4.8.90 - 6.1.6.Final - 3.0.0 - 3.6.0 - 2.22.2 - 3.8.1 - 2.5.3 - 3.0 - + 17 + + + 3.5 + 2.5.4 + 4.8.184 + 2.0.17 - - easy-random-core - easy-random-bean-validation - easy-random-randomizers - + + 6.1.0 + 3.27.7 + 5.23.0 + + + 3.5.5 + 3.15.0 + 3.3.1 + 5.0.0 + git@github.com:j-easy/easy-random.git @@ -67,9 +64,9 @@ - benas + fmbenhassine Mahmoud Ben Hassine - http://benas.github.io + http://fmbenhassine.github.io mahmoud.benhassine@icloud.com Lead developer @@ -85,108 +82,91 @@ - - - - org.jeasy - easy-random-core - ${project.version} - - - org.jeasy - easy-random-randomizers - ${project.version} - - - javax.validation - validation-api - ${validation-api.version} - - - org.objenesis - objenesis - ${objenesis.version} - - - io.github.classgraph - classgraph - ${classgraph.version} - true - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - - - org.glassfish - javax.el - ${javax.el.version} - - - com.github.javafaker - javafaker - ${faker.version} - - - org.junit.jupiter - junit-jupiter - ${junit.version} - - - org.assertj - assertj-core - ${assertj.version} - - - org.mockito - mockito-core - ${mockito.version} - - - org.mockito - mockito-junit-jupiter - ${mockito.version} - + + + org.objenesis + objenesis + ${objenesis.version} + + + io.github.classgraph + classgraph + ${classgraph.version} + + + net.datafaker + datafaker + ${datafaker.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.junit.jupiter + junit-jupiter + ${junit.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - true - ${java.version} - true - - -verbose - -Xlint:unchecked - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - **/*Test*.java - - html - - - - org.apache.maven.plugins - maven-release-plugin - ${maven-release-plugin.version} - - - + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + true + ${java.version} + true + + -verbose + -Xlint:unchecked + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*Test*.java + + html + + + + org.apache.maven.plugins + maven-release-plugin + ${maven-release-plugin.version} + com.mycila license-maven-plugin @@ -194,7 +174,7 @@
licence-header-template.txt
- 2020 + 2023 true diff --git a/easy-random-core/src/main/java/org/jeasy/random/ArrayPopulator.java b/src/main/java/org/jeasy/random/ArrayPopulator.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/ArrayPopulator.java rename to src/main/java/org/jeasy/random/ArrayPopulator.java index 557317283..ac2fddd6f 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/ArrayPopulator.java +++ b/src/main/java/org/jeasy/random/ArrayPopulator.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/CollectionPopulator.java b/src/main/java/org/jeasy/random/CollectionPopulator.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/CollectionPopulator.java rename to src/main/java/org/jeasy/random/CollectionPopulator.java index 0ce481eb9..2b51f52cf 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/CollectionPopulator.java +++ b/src/main/java/org/jeasy/random/CollectionPopulator.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/DefaultExclusionPolicy.java b/src/main/java/org/jeasy/random/DefaultExclusionPolicy.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/DefaultExclusionPolicy.java rename to src/main/java/org/jeasy/random/DefaultExclusionPolicy.java index 3de2b50a0..54cec0917 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/DefaultExclusionPolicy.java +++ b/src/main/java/org/jeasy/random/DefaultExclusionPolicy.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/EasyRandom.java b/src/main/java/org/jeasy/random/EasyRandom.java similarity index 83% rename from easy-random-core/src/main/java/org/jeasy/random/EasyRandom.java rename to src/main/java/org/jeasy/random/EasyRandom.java index 040d750db..88f19f0bd 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/EasyRandom.java +++ b/src/main/java/org/jeasy/random/EasyRandom.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,6 +28,7 @@ import org.jeasy.random.util.ReflectionUtils; import java.lang.reflect.Field; +import java.lang.reflect.RecordComponent; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; @@ -72,8 +73,7 @@ public EasyRandom(final EasyRandomParameters easyRandomParameters) { Objects.requireNonNull(easyRandomParameters, "Parameters must not be null"); super.setSeed(easyRandomParameters.getSeed()); LinkedHashSet registries = setupRandomizerRegistries(easyRandomParameters); - RandomizerProvider customRandomizerProvider = easyRandomParameters.getRandomizerProvider(); - randomizerProvider = customRandomizerProvider == null ? new RegistriesRandomizerProvider() : customRandomizerProvider; + randomizerProvider = easyRandomParameters.getRandomizerProvider(); randomizerProvider.setRandomizerRegistries(registries); objectFactory = easyRandomParameters.getObjectFactory(); arrayPopulator = new ArrayPopulator(this); @@ -97,7 +97,11 @@ public EasyRandom(final EasyRandomParameters easyRandomParameters) { * @throws ObjectCreationException when unable to create a new instance of the given type */ public T nextObject(final Class type) { - return doPopulateBean(type, new RandomizationContext(type, parameters)); + if (type.isRecord()) { + return createRandomRecord(type, new RandomizationContext(type, parameters)); + } else { + return doPopulateBean(type, new RandomizationContext(type, parameters)); + } } /** @@ -117,6 +121,26 @@ public Stream objects(final Class type, final int streamSize) { return Stream.generate(() -> nextObject(type)).limit(streamSize); } + private T createRandomRecord(Class recordType, final RandomizationContext context) { + // generate random values for record components + RecordComponent[] recordComponents = recordType.getRecordComponents(); + Object[] randomValues = new Object[recordComponents.length]; + for (int i = 0; i < recordComponents.length; i++) { + Class recordComponentType = recordComponents[i].getType(); + if (recordComponentType.isRecord()) { + randomValues[i] = this.createRandomRecord(recordComponentType, context); + } else { + randomValues[i] = this.nextObject(recordComponentType); + } + } + // create a random instance with random values + try { + return getCanonicalConstructor(recordType).newInstance(randomValues); + } catch (Exception e) { + throw new ObjectCreationException("Unable to create a random instance of recordType " + recordType, e); + } + } + T doPopulateBean(final Class type, final RandomizationContext context) { if (exclusionPolicy.shouldBeExcluded(type, context)) { return null; @@ -143,6 +167,11 @@ T doPopulateBean(final Class type, final RandomizationContext context) { return (T) context.getPopulatedBean(type); } + // Records are populated differently since they are immutable and their state is defined by their record components + if (type.isRecord()) { + return createRandomRecord(type, context); + } + // create a new instance of the target type result = objectFactory.createInstance(type, context); context.setRandomizedObject(result); @@ -151,7 +180,7 @@ T doPopulateBean(final Class type, final RandomizationContext context) { context.addPopulatedBean(type, result); // retrieve declared and inherited fields - List fields = getDeclaredFields(result); + List fields = getDeclaredFields(result.getClass()); // we cannot use type here, because with classpath scanning enabled the result can be a subtype fields.addAll(getInheritedFields(result.getClass())); @@ -203,7 +232,7 @@ private void populateField(final Field field, final T result, final Randomiz if (exclusionPolicy.shouldBeExcluded(field, context)) { return; } - if (!parameters.isOverrideDefaultInitialization() && getFieldValue(result, field) != null && !isPrimitiveFieldWithDefaultValue(result, field)) { + if (!parameters.isOverrideDefaultInitialization() && getProperty(result, field) != null && !isPrimitiveFieldWithDefaultValue(result, field)) { return; } fieldPopulator.populateField(result, field, context); diff --git a/easy-random-core/src/main/java/org/jeasy/random/EasyRandomParameters.java b/src/main/java/org/jeasy/random/EasyRandomParameters.java similarity index 99% rename from easy-random-core/src/main/java/org/jeasy/random/EasyRandomParameters.java rename to src/main/java/org/jeasy/random/EasyRandomParameters.java index 991647685..4215f8a19 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/EasyRandomParameters.java +++ b/src/main/java/org/jeasy/random/EasyRandomParameters.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -136,6 +136,7 @@ public EasyRandomParameters() { typeExclusionPredicates = new HashSet<>(); exclusionPolicy = new DefaultExclusionPolicy(); objectFactory = new ObjenesisObjectFactory(); + randomizerProvider = new RegistriesRandomizerProvider(); } public Range getCollectionSizeRange() { @@ -250,7 +251,7 @@ public RandomizerProvider getRandomizerProvider() { return randomizerProvider; } public void setRandomizerProvider(RandomizerProvider randomizerProvider) { - Objects.requireNonNull(objectFactory, "Randomizer provider must not be null"); + Objects.requireNonNull(randomizerProvider, "Randomizer provider must not be null"); this.randomizerProvider = randomizerProvider; } diff --git a/easy-random-core/src/main/java/org/jeasy/random/FieldPopulator.java b/src/main/java/org/jeasy/random/FieldPopulator.java similarity index 67% rename from easy-random-core/src/main/java/org/jeasy/random/FieldPopulator.java rename to src/main/java/org/jeasy/random/FieldPopulator.java index 482c75833..d23fa50d0 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/FieldPopulator.java +++ b/src/main/java/org/jeasy/random/FieldPopulator.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,12 +25,16 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.TypeVariable; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.jeasy.random.api.ContextAwareRandomizer; import org.jeasy.random.api.Randomizer; import org.jeasy.random.api.RandomizerProvider; import org.jeasy.random.randomizers.misc.SkipRandomizer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -52,6 +56,8 @@ */ class FieldPopulator { + private static final Logger logger = LoggerFactory.getLogger(FieldPopulator.class); + private final EasyRandom easyRandom; private final ArrayPopulator arrayPopulator; @@ -76,7 +82,7 @@ class FieldPopulator { } void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { - Randomizer randomizer = getRandomizer(field, context); + Randomizer randomizer = getRandomizer(field, target.getClass(), context); if (randomizer instanceof SkipRandomizer) { return; } @@ -90,7 +96,7 @@ void populateField(final Object target, final Field field, final RandomizationCo value = randomizer.getRandomValue(); } else { try { - value = generateRandomValue(field, context); + value = generateRandomValue(field, target.getClass(), context); } catch (ObjectCreationException e) { String exceptionMessage = String.format("Unable to create type: %s for field: %s of class: %s", field.getType().getName(), field.getName(), target.getClass().getName()); @@ -109,18 +115,21 @@ void populateField(final Object target, final Field field, final RandomizationCo throw new ObjectCreationException(exceptionMessage, e.getCause()); } } + } else { + logger.warn("Skipping populating field {}#{} as the randomization depth has been reached: {}", + field.getDeclaringClass().getSimpleName(), field.getName(), context.getParameters().getRandomizationDepth()); } context.popStackItem(); } - private Randomizer getRandomizer(Field field, RandomizationContext context) { + private Randomizer getRandomizer(Field field, Class owningType, RandomizationContext context) { // issue 241: if there is no custom randomizer by field, then check by type Randomizer randomizer = randomizerProvider.getRandomizerByField(field, context); if (randomizer == null) { Type genericType = field.getGenericType(); if (isTypeVariable(genericType)) { // if generic type, retrieve actual type from declaring class - Class type = getParametrizedType(field, context); + Class type = getParametrizedType(field, owningType); randomizer = randomizerProvider.getRandomizerByType(type, context); } else { randomizer = randomizerProvider.getRandomizerByType(field.getType(), context); @@ -129,7 +138,7 @@ private Randomizer getRandomizer(Field field, RandomizationContext context) { return randomizer; } - private Object generateRandomValue(final Field field, final RandomizationContext context) { + private Object generateRandomValue(final Field field, final Class owningType, final RandomizationContext context) { Class fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); @@ -141,6 +150,10 @@ private Object generateRandomValue(final Field field, final RandomizationContext return mapPopulator.getRandomMap(field, context); } else if (isOptionalType(fieldType)) { return optionalPopulator.getRandomOptional(field, context); + } else if (isTypeVariable(fieldGenericType)) { + // Resolve generic type variables before falling back to the erased field type. + Class type = getParametrizedType(field, owningType); + return easyRandom.doPopulateBean(type, context); } else { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(fieldType) && !isEnumType(fieldType) /*enums can be abstract, but cannot inherit*/) { List> parameterizedTypes = filterSameParameterizedTypes(getPublicConcreteSubTypesOf(fieldType), fieldGenericType); @@ -151,56 +164,62 @@ private Object generateRandomValue(final Field field, final RandomizationContext return easyRandom.doPopulateBean(randomConcreteSubType, context); } } else { - Type genericType = field.getGenericType(); - if (isTypeVariable(genericType)) { - // if generic type, try to retrieve actual type from hierarchy - Class type = getParametrizedType(field, context); - return easyRandom.doPopulateBean(type, context); - } return easyRandom.doPopulateBean(fieldType, context); } } } - private Class getParametrizedType(Field field, RandomizationContext context) { - Class declaringClass = field.getDeclaringClass(); - TypeVariable>[] typeParameters = declaringClass.getTypeParameters(); - Type genericSuperclass = getGenericSuperClass(context); - ParameterizedType parameterizedGenericSuperType = (ParameterizedType) genericSuperclass; - Type[] actualTypeArguments = parameterizedGenericSuperType.getActualTypeArguments(); - Type actualTypeArgument = null; - for (int i = 0; i < typeParameters.length; i++) { - if (field.getGenericType().equals(typeParameters[i])) { - actualTypeArgument = actualTypeArguments[i]; - } - } + private Class getParametrizedType(Field field, Class owningType) { + Type actualTypeArgument = resolveTypeVariable(field, owningType); if (actualTypeArgument == null) { - return field.getClass(); + return field.getType(); } - Class aClass; - String typeName = null; - try { - typeName = actualTypeArgument.getTypeName(); - aClass = Class.forName(typeName); - } catch (ClassNotFoundException e) { - String message = String.format("Unable to load class %s of generic field %s in class %s. " + - "Please refer to the documentation as this generic type may not be supported for randomization.", - typeName, field.getName(), field.getDeclaringClass().getName()); - throw new ObjectCreationException(message, e); - } - return aClass; + return toClass(actualTypeArgument, field); } - // find the generic base class in the hierarchy (which might not be the first super type) - private Type getGenericSuperClass(RandomizationContext context) { - Class targetType = context.getTargetType(); - Type genericSuperclass = targetType.getGenericSuperclass(); - while (targetType != null && !(genericSuperclass instanceof ParameterizedType)) { - targetType = targetType.getSuperclass(); - if (targetType != null) { - genericSuperclass = targetType.getGenericSuperclass(); + private Type resolveTypeVariable(Field field, Class targetType) { + Map, Type> typeMapping = new HashMap<>(); + Class currentType = targetType; + + while (currentType != null) { + Type genericSuperclass = currentType.getGenericSuperclass(); + if (genericSuperclass instanceof ParameterizedType parameterizedType) { + Class rawType = (Class) parameterizedType.getRawType(); + TypeVariable>[] typeParameters = rawType.getTypeParameters(); + Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); + + for (int i = 0; i < typeParameters.length; i++) { + typeMapping.put(typeParameters[i], resolveType(actualTypeArguments[i], typeMapping)); + } + + if (rawType.equals(field.getDeclaringClass())) { + return resolveType(field.getGenericType(), typeMapping); + } + currentType = rawType; + } else if (genericSuperclass instanceof Class) { + currentType = (Class) genericSuperclass; + } else { + currentType = null; } } - return genericSuperclass; + return null; + } + + private Type resolveType(Type type, Map, Type> typeMapping) { + Type resolvedType = type; + while (resolvedType instanceof TypeVariable && typeMapping.containsKey(resolvedType)) { + resolvedType = typeMapping.get(resolvedType); + } + return resolvedType; + } + + private Class toClass(Type type, Field field) { + if (type instanceof Class) { + return (Class) type; + } + String message = String.format("Unable to resolve generic field %s in class %s to a concrete class. " + + "Please refer to the documentation as this generic type may not be supported for randomization.", + field.getName(), field.getDeclaringClass().getName()); + throw new ObjectCreationException(message); } } diff --git a/easy-random-core/src/main/java/org/jeasy/random/FieldPredicates.java b/src/main/java/org/jeasy/random/FieldPredicates.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/FieldPredicates.java rename to src/main/java/org/jeasy/random/FieldPredicates.java index b12b9ddd1..5c480b07e 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/FieldPredicates.java +++ b/src/main/java/org/jeasy/random/FieldPredicates.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/MapPopulator.java b/src/main/java/org/jeasy/random/MapPopulator.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/MapPopulator.java rename to src/main/java/org/jeasy/random/MapPopulator.java index ef2bab53a..cc40e7e1e 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/MapPopulator.java +++ b/src/main/java/org/jeasy/random/MapPopulator.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/ObjectCreationException.java b/src/main/java/org/jeasy/random/ObjectCreationException.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/ObjectCreationException.java rename to src/main/java/org/jeasy/random/ObjectCreationException.java index f50ada748..9184aa648 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/ObjectCreationException.java +++ b/src/main/java/org/jeasy/random/ObjectCreationException.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/ObjenesisObjectFactory.java b/src/main/java/org/jeasy/random/ObjenesisObjectFactory.java similarity index 88% rename from easy-random-core/src/main/java/org/jeasy/random/ObjenesisObjectFactory.java rename to src/main/java/org/jeasy/random/ObjenesisObjectFactory.java index 9db492fd9..b6276710d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/ObjenesisObjectFactory.java +++ b/src/main/java/org/jeasy/random/ObjenesisObjectFactory.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,7 +24,6 @@ package org.jeasy.random; import java.util.List; -import java.util.Random; import org.jeasy.random.api.ObjectFactory; import org.jeasy.random.api.RandomizerContext; import org.objenesis.Objenesis; @@ -45,12 +44,12 @@ public class ObjenesisObjectFactory implements ObjectFactory { private final Objenesis objenesis = new ObjenesisStd(); - private Random random; + private EasyRandom random; @Override public T createInstance(Class type, RandomizerContext context) { if (random == null) { - random = new Random(context.getParameters().getSeed()); + random = new EasyRandom(context.getParameters()); } if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { List> publicConcreteSubTypes = getPublicConcreteSubTypesOf(type); @@ -58,7 +57,11 @@ public T createInstance(Class type, RandomizerContext context) { throw new InstantiationError("Unable to find a matching concrete subtype of type: " + type + " in the classpath"); } else { Class randomConcreteSubType = publicConcreteSubTypes.get(random.nextInt(publicConcreteSubTypes.size())); - return (T) createNewInstance(randomConcreteSubType); + if (randomConcreteSubType.isRecord()) { + return (T) random.nextObject(randomConcreteSubType); + } else { + return (T) createNewInstance(randomConcreteSubType); + } } } else { try { diff --git a/easy-random-core/src/main/java/org/jeasy/random/OptionalPopulator.java b/src/main/java/org/jeasy/random/OptionalPopulator.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/OptionalPopulator.java rename to src/main/java/org/jeasy/random/OptionalPopulator.java index c7c326cdf..28b8c087f 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/OptionalPopulator.java +++ b/src/main/java/org/jeasy/random/OptionalPopulator.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/PriorityComparator.java b/src/main/java/org/jeasy/random/PriorityComparator.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/PriorityComparator.java rename to src/main/java/org/jeasy/random/PriorityComparator.java index e11c24721..97f3711d0 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/PriorityComparator.java +++ b/src/main/java/org/jeasy/random/PriorityComparator.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/RandomizationContext.java b/src/main/java/org/jeasy/random/RandomizationContext.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/RandomizationContext.java rename to src/main/java/org/jeasy/random/RandomizationContext.java index 537eeac1b..c40417179 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/RandomizationContext.java +++ b/src/main/java/org/jeasy/random/RandomizationContext.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/RandomizationContextStackItem.java b/src/main/java/org/jeasy/random/RandomizationContextStackItem.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/RandomizationContextStackItem.java rename to src/main/java/org/jeasy/random/RandomizationContextStackItem.java index 391d330a5..9ae8f5192 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/RandomizationContextStackItem.java +++ b/src/main/java/org/jeasy/random/RandomizationContextStackItem.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/RegistriesRandomizerProvider.java b/src/main/java/org/jeasy/random/RegistriesRandomizerProvider.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/RegistriesRandomizerProvider.java rename to src/main/java/org/jeasy/random/RegistriesRandomizerProvider.java index 5325b87d3..b0c02fa03 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/RegistriesRandomizerProvider.java +++ b/src/main/java/org/jeasy/random/RegistriesRandomizerProvider.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/TypePredicates.java b/src/main/java/org/jeasy/random/TypePredicates.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/TypePredicates.java rename to src/main/java/org/jeasy/random/TypePredicates.java index 528300bf1..90466013d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/TypePredicates.java +++ b/src/main/java/org/jeasy/random/TypePredicates.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/annotation/Exclude.java b/src/main/java/org/jeasy/random/annotation/Exclude.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/annotation/Exclude.java rename to src/main/java/org/jeasy/random/annotation/Exclude.java index 2f0f2148b..7677050fb 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/annotation/Exclude.java +++ b/src/main/java/org/jeasy/random/annotation/Exclude.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/annotation/Priority.java b/src/main/java/org/jeasy/random/annotation/Priority.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/annotation/Priority.java rename to src/main/java/org/jeasy/random/annotation/Priority.java index 11f926364..a667a6e44 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/annotation/Priority.java +++ b/src/main/java/org/jeasy/random/annotation/Priority.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/annotation/Randomizer.java b/src/main/java/org/jeasy/random/annotation/Randomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/annotation/Randomizer.java rename to src/main/java/org/jeasy/random/annotation/Randomizer.java index a8d37021e..50b21b982 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/annotation/Randomizer.java +++ b/src/main/java/org/jeasy/random/annotation/Randomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/annotation/RandomizerArgument.java b/src/main/java/org/jeasy/random/annotation/RandomizerArgument.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/annotation/RandomizerArgument.java rename to src/main/java/org/jeasy/random/annotation/RandomizerArgument.java index 0e3cfd5e6..34aadd249 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/annotation/RandomizerArgument.java +++ b/src/main/java/org/jeasy/random/annotation/RandomizerArgument.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/annotation/package-info.java b/src/main/java/org/jeasy/random/annotation/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/annotation/package-info.java rename to src/main/java/org/jeasy/random/annotation/package-info.java index 925cfd9a1..371a4b47d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/annotation/package-info.java +++ b/src/main/java/org/jeasy/random/annotation/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/ContextAwareRandomizer.java b/src/main/java/org/jeasy/random/api/ContextAwareRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/api/ContextAwareRandomizer.java rename to src/main/java/org/jeasy/random/api/ContextAwareRandomizer.java index e0a5ef53d..4d788e1bd 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/ContextAwareRandomizer.java +++ b/src/main/java/org/jeasy/random/api/ContextAwareRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/ExclusionPolicy.java b/src/main/java/org/jeasy/random/api/ExclusionPolicy.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/api/ExclusionPolicy.java rename to src/main/java/org/jeasy/random/api/ExclusionPolicy.java index 17c59acfc..44229ea71 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/ExclusionPolicy.java +++ b/src/main/java/org/jeasy/random/api/ExclusionPolicy.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/ObjectFactory.java b/src/main/java/org/jeasy/random/api/ObjectFactory.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/api/ObjectFactory.java rename to src/main/java/org/jeasy/random/api/ObjectFactory.java index a426d8085..b3282dad3 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/ObjectFactory.java +++ b/src/main/java/org/jeasy/random/api/ObjectFactory.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/Randomizer.java b/src/main/java/org/jeasy/random/api/Randomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/api/Randomizer.java rename to src/main/java/org/jeasy/random/api/Randomizer.java index 4168ebbb5..d2a6cf6fb 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/Randomizer.java +++ b/src/main/java/org/jeasy/random/api/Randomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/RandomizerContext.java b/src/main/java/org/jeasy/random/api/RandomizerContext.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/api/RandomizerContext.java rename to src/main/java/org/jeasy/random/api/RandomizerContext.java index 4f56d2f5b..f74fa6ecb 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/RandomizerContext.java +++ b/src/main/java/org/jeasy/random/api/RandomizerContext.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/RandomizerProvider.java b/src/main/java/org/jeasy/random/api/RandomizerProvider.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/api/RandomizerProvider.java rename to src/main/java/org/jeasy/random/api/RandomizerProvider.java index 73ffc3f2b..a9cd31b90 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/RandomizerProvider.java +++ b/src/main/java/org/jeasy/random/api/RandomizerProvider.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/RandomizerRegistry.java b/src/main/java/org/jeasy/random/api/RandomizerRegistry.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/api/RandomizerRegistry.java rename to src/main/java/org/jeasy/random/api/RandomizerRegistry.java index a789dad7a..b41f80c46 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/RandomizerRegistry.java +++ b/src/main/java/org/jeasy/random/api/RandomizerRegistry.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/api/package-info.java b/src/main/java/org/jeasy/random/api/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/api/package-info.java rename to src/main/java/org/jeasy/random/api/package-info.java index b313629b3..1b05934d2 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/api/package-info.java +++ b/src/main/java/org/jeasy/random/api/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/package-info.java b/src/main/java/org/jeasy/random/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/package-info.java rename to src/main/java/org/jeasy/random/package-info.java index a4c9b6dd2..477dbebc2 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/package-info.java +++ b/src/main/java/org/jeasy/random/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/AbstractRandomizer.java b/src/main/java/org/jeasy/random/randomizers/AbstractRandomizer.java similarity index 74% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/AbstractRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/AbstractRandomizer.java index e7ae4ae54..d5b73ec96 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/AbstractRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/AbstractRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -74,4 +74,34 @@ protected double nextDouble(final double min, final double max) { // NB: ThreadLocalRandom.current().nextDouble(min, max)) cannot be used // because the seed is not configurable and is created per thread (see Javadoc) } + + /** + * Return a random int in the given range. + * + * @param min value (inclusive) + * @param max value (inclusive) + * @return random int in the given range + */ + protected int nextInt(final int min, final int max) { + return random.nextInt((max - min) + 1) + min; + } + + /** + * Return a random long in the given range. + * + * @param min value (inclusive) + * @param max value (inclusive) + * @return random long in the given range + */ + protected long nextLong(final long min, final long max) { + long bound = max - min + 1; + if (bound > 0) { + return min + (long) (random.nextDouble() * bound); + } + long value; + do { + value = random.nextLong(); + } while (value < min || value > max); + return value; + } } diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CityRandomizer.java b/src/main/java/org/jeasy/random/randomizers/CityRandomizer.java similarity index 96% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CityRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/CityRandomizer.java index 0fb795dc6..9e9d1c01a 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CityRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/CityRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CompanyRandomizer.java b/src/main/java/org/jeasy/random/randomizers/CompanyRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CompanyRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/CompanyRandomizer.java index d7b85f45b..b0f2f16dc 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CompanyRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/CompanyRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CountryRandomizer.java b/src/main/java/org/jeasy/random/randomizers/CountryRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CountryRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/CountryRandomizer.java index 69ff6d37f..ee1f4f297 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CountryRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/CountryRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CreditCardNumberRandomizer.java b/src/main/java/org/jeasy/random/randomizers/CreditCardNumberRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CreditCardNumberRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/CreditCardNumberRandomizer.java index b0b762371..e3da02d82 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/CreditCardNumberRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/CreditCardNumberRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/EmailRandomizer.java b/src/main/java/org/jeasy/random/randomizers/EmailRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/EmailRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/EmailRandomizer.java index b5207b8e0..39a39f0b3 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/EmailRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/EmailRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FakerBasedRandomizer.java b/src/main/java/org/jeasy/random/randomizers/FakerBasedRandomizer.java similarity index 93% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FakerBasedRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/FakerBasedRandomizer.java index c78d4438a..f15047044 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FakerBasedRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/FakerBasedRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,13 +23,13 @@ */ package org.jeasy.random.randomizers; -import com.github.javafaker.Faker; +import net.datafaker.Faker; import org.jeasy.random.api.Randomizer; import java.util.Locale; /** - * Abstract {@link Randomizer} based on Faker. + * Abstract {@link Randomizer} based on Data Faker. * * @param the element type * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FirstNameRandomizer.java b/src/main/java/org/jeasy/random/randomizers/FirstNameRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FirstNameRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/FirstNameRandomizer.java index 8b97c81c3..83c50170a 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FirstNameRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/FirstNameRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FullNameRandomizer.java b/src/main/java/org/jeasy/random/randomizers/FullNameRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FullNameRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/FullNameRandomizer.java index 3b79b2497..7009f7985 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/FullNameRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/FullNameRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/GenericStringRandomizer.java b/src/main/java/org/jeasy/random/randomizers/GenericStringRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/GenericStringRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/GenericStringRandomizer.java index efbdf11a0..3f414387d 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/GenericStringRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/GenericStringRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/Ipv4AddressRandomizer.java b/src/main/java/org/jeasy/random/randomizers/Ipv4AddressRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/Ipv4AddressRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/Ipv4AddressRandomizer.java index 6609a662e..fbc4bf530 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/Ipv4AddressRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/Ipv4AddressRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/Ipv6AddressRandomizer.java b/src/main/java/org/jeasy/random/randomizers/Ipv6AddressRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/Ipv6AddressRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/Ipv6AddressRandomizer.java index 79c9a5206..a3da84307 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/Ipv6AddressRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/Ipv6AddressRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/IsbnRandomizer.java b/src/main/java/org/jeasy/random/randomizers/IsbnRandomizer.java similarity index 96% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/IsbnRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/IsbnRandomizer.java index c7bb5c3d9..8d0923365 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/IsbnRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/IsbnRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LastNameRandomizer.java b/src/main/java/org/jeasy/random/randomizers/LastNameRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LastNameRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/LastNameRandomizer.java index decf155bc..8e9fa9411 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LastNameRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/LastNameRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LatitudeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/LatitudeRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LatitudeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/LatitudeRandomizer.java index b6d7dd116..f2a16ae5e 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LatitudeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/LatitudeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LongitudeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/LongitudeRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LongitudeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/LongitudeRandomizer.java index 049ba8f2e..e3db0db54 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/LongitudeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/LongitudeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/MacAddressRandomizer.java b/src/main/java/org/jeasy/random/randomizers/MacAddressRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/MacAddressRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/MacAddressRandomizer.java index 7e48a1bf8..993d5200e 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/MacAddressRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/MacAddressRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/ParagraphRandomizer.java b/src/main/java/org/jeasy/random/randomizers/ParagraphRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/ParagraphRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/ParagraphRandomizer.java index 37c49acb1..cbe9fd956 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/ParagraphRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/ParagraphRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/PasswordRandomizer.java b/src/main/java/org/jeasy/random/randomizers/PasswordRandomizer.java similarity index 98% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/PasswordRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/PasswordRandomizer.java index 92dd8b4fb..f001cd2d8 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/PasswordRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/PasswordRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/PhoneNumberRandomizer.java b/src/main/java/org/jeasy/random/randomizers/PhoneNumberRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/PhoneNumberRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/PhoneNumberRandomizer.java index 8e417b697..3d6633bd4 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/PhoneNumberRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/PhoneNumberRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/RegularExpressionRandomizer.java b/src/main/java/org/jeasy/random/randomizers/RegularExpressionRandomizer.java similarity index 98% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/RegularExpressionRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/RegularExpressionRandomizer.java index ef3d3f179..45165a8bf 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/RegularExpressionRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/RegularExpressionRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/SentenceRandomizer.java b/src/main/java/org/jeasy/random/randomizers/SentenceRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/SentenceRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/SentenceRandomizer.java index 576265fb5..09f70a789 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/SentenceRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/SentenceRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/StateRandomizer.java b/src/main/java/org/jeasy/random/randomizers/StateRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/StateRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/StateRandomizer.java index 46f3679ad..7f2290188 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/StateRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/StateRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/StreetRandomizer.java b/src/main/java/org/jeasy/random/randomizers/StreetRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/StreetRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/StreetRandomizer.java index 8e7fa9074..986d3cd88 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/StreetRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/StreetRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/WordRandomizer.java b/src/main/java/org/jeasy/random/randomizers/WordRandomizer.java similarity index 96% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/WordRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/WordRandomizer.java index e8d6028e2..5d72e91aa 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/WordRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/WordRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/ZipCodeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/ZipCodeRandomizer.java similarity index 97% rename from easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/ZipCodeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/ZipCodeRandomizer.java index c749d2c2f..81ee11acd 100644 --- a/easy-random-randomizers/src/main/java/org/jeasy/random/randomizers/ZipCodeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/ZipCodeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/CollectionRandomizer.java b/src/main/java/org/jeasy/random/randomizers/collection/CollectionRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/CollectionRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/collection/CollectionRandomizer.java index 9c228b598..4abdc3516 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/CollectionRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/collection/CollectionRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/EnumSetRandomizer.java b/src/main/java/org/jeasy/random/randomizers/collection/EnumSetRandomizer.java similarity index 94% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/EnumSetRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/collection/EnumSetRandomizer.java index 5293494a8..c615889a9 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/EnumSetRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/collection/EnumSetRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -62,8 +62,9 @@ public EnumSetRandomizer(final EnumRandomizer delegate, final int nbElements) @Override public EnumSet getRandomValue() { + int size = Math.max(1, nbElements); List elements = new ArrayList<>(); - for (int i = 0; i < nbElements; i++) { + for (int i = 0; i < size; i++) { elements.add(getRandomElement()); } return EnumSet.copyOf(elements); diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/ListRandomizer.java b/src/main/java/org/jeasy/random/randomizers/collection/ListRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/ListRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/collection/ListRandomizer.java index 9179e0067..5b9623b44 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/ListRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/collection/ListRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/MapRandomizer.java b/src/main/java/org/jeasy/random/randomizers/collection/MapRandomizer.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/MapRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/collection/MapRandomizer.java index e5c779676..eecd35817 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/MapRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/collection/MapRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/QueueRandomizer.java b/src/main/java/org/jeasy/random/randomizers/collection/QueueRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/QueueRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/collection/QueueRandomizer.java index 3a6d70768..ca05850d0 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/QueueRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/collection/QueueRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/SetRandomizer.java b/src/main/java/org/jeasy/random/randomizers/collection/SetRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/SetRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/collection/SetRandomizer.java index 7baa99b5e..a02cef285 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/SetRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/collection/SetRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/package-info.java b/src/main/java/org/jeasy/random/randomizers/collection/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/package-info.java rename to src/main/java/org/jeasy/random/randomizers/collection/package-info.java index 91fd55e98..1b4b20104 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/collection/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/collection/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/BooleanRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/BooleanRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/BooleanRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/BooleanRandomizer.java index 8e8d18183..8a6a3f3e9 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/BooleanRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/BooleanRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/ConstantRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/ConstantRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/ConstantRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/ConstantRandomizer.java index b71fbea5a..62bcc9ade 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/ConstantRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/ConstantRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/EnumRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/EnumRandomizer.java similarity index 84% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/EnumRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/EnumRandomizer.java index 8de1c064d..919dbdeed 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/EnumRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/EnumRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -75,6 +75,21 @@ public EnumRandomizer(final Class enumeration, final E... excludedValues) thr this.enumConstants = getFilteredList(enumeration, excludedValues); } + /** + * Create a new {@link EnumRandomizer}. + * + * @param enumeration the enumeration from which this randomizer will generate random values + * @param seed the initial seed + * @param excludedValues the values to exclude from random picking + * @throws IllegalArgumentException when excludedValues contains all enumeration values, + * ie all elements from the enumeration are excluded + */ + public EnumRandomizer(final Class enumeration, final long seed, final E... excludedValues) throws IllegalArgumentException { + super(seed); + checkExcludedValues(enumeration, excludedValues); + this.enumConstants = getFilteredList(enumeration, excludedValues); + } + /** * Get a random value within an enumeration or an enumeration subset (when values are excluded) * diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/LocaleRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/LocaleRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/LocaleRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/LocaleRandomizer.java index 77d0a2150..53671cf7b 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/LocaleRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/LocaleRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/NullRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/NullRandomizer.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/NullRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/NullRandomizer.java index 66183b108..f2e320ee7 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/NullRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/NullRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/OptionalRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/OptionalRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/OptionalRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/OptionalRandomizer.java index 474973ac3..3ff54ac0d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/OptionalRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/OptionalRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/SkipRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/SkipRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/SkipRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/SkipRandomizer.java index 14372bac7..0632daa43 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/SkipRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/SkipRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/UUIDRandomizer.java b/src/main/java/org/jeasy/random/randomizers/misc/UUIDRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/UUIDRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/misc/UUIDRandomizer.java index 75a05a6ce..19ea9864f 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/UUIDRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/UUIDRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/package-info.java b/src/main/java/org/jeasy/random/randomizers/misc/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/package-info.java rename to src/main/java/org/jeasy/random/randomizers/misc/package-info.java index f9d238496..6dc290ed7 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/misc/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/misc/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/net/UriRandomizer.java b/src/main/java/org/jeasy/random/randomizers/net/UriRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/net/UriRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/net/UriRandomizer.java index 537e9b4cc..590c16fbb 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/net/UriRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/net/UriRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/net/UrlRandomizer.java b/src/main/java/org/jeasy/random/randomizers/net/UrlRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/net/UrlRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/net/UrlRandomizer.java index 1c0bac96b..ad55df0e6 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/net/UrlRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/net/UrlRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/net/package-info.java b/src/main/java/org/jeasy/random/randomizers/net/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/net/package-info.java rename to src/main/java/org/jeasy/random/randomizers/net/package-info.java index 612c35f73..0d1063ddf 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/net/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/net/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizer.java index 577477646..ae3eb1530 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/AtomicLongRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/AtomicLongRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/AtomicLongRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/AtomicLongRandomizer.java index 0ac112d6c..408940e9d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/AtomicLongRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/AtomicLongRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/BigDecimalRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/BigDecimalRandomizer.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/BigDecimalRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/BigDecimalRandomizer.java index 93b0e08ec..fdec9a54c 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/BigDecimalRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/BigDecimalRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/BigIntegerRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/BigIntegerRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/BigIntegerRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/BigIntegerRandomizer.java index 49ea1692e..387587613 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/BigIntegerRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/BigIntegerRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/ByteRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/ByteRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/ByteRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/ByteRandomizer.java index 0b38e5da9..3c71ffae3 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/ByteRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/ByteRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/DoubleRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/DoubleRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/DoubleRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/DoubleRandomizer.java index a1aaede6c..4eae21612 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/DoubleRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/DoubleRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/FloatRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/FloatRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/FloatRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/FloatRandomizer.java index 04c0d0e1d..4a4ce7d52 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/FloatRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/FloatRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/IntegerRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/IntegerRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/IntegerRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/IntegerRandomizer.java index f7867dd52..900f6df65 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/IntegerRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/IntegerRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/LongRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/LongRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/LongRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/LongRandomizer.java index 386d1e41d..c9750b5b6 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/LongRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/LongRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/NumberRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/NumberRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/NumberRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/NumberRandomizer.java index 54fcdac8e..44dd6ee2c 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/NumberRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/NumberRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/ShortRandomizer.java b/src/main/java/org/jeasy/random/randomizers/number/ShortRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/ShortRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/number/ShortRandomizer.java index 30bd5dc92..332006b0b 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/ShortRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/number/ShortRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/package-info.java b/src/main/java/org/jeasy/random/randomizers/number/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/number/package-info.java rename to src/main/java/org/jeasy/random/randomizers/number/package-info.java index 21d0fae05..26582444c 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/number/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/number/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/package-info.java b/src/main/java/org/jeasy/random/randomizers/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/package-info.java rename to src/main/java/org/jeasy/random/randomizers/package-info.java index c9979cf55..4557f349e 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizer.java index 0d78d006d..fb384441f 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java index 35623d027..a6096d1b0 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -81,7 +81,8 @@ public BigDecimalRangeRandomizer(final Double min, final Double max, final Integ * @param roundingMode of the {@code BigDecimal} value to be returned. */ public BigDecimalRangeRandomizer(final Double min, final Double max, final Integer scale, final RoundingMode roundingMode) { - delegate = new DoubleRangeRandomizer(min, max, scale); + delegate = new DoubleRangeRandomizer(min, max); + this.scale = scale; this.roundingMode = roundingMode; } diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizer.java index 434336884..39a435f95 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ByteRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/ByteRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ByteRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/ByteRangeRandomizer.java index d70ad1612..3200f14c2 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ByteRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/ByteRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/DateRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/DateRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/DateRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/DateRangeRandomizer.java index 86832512e..e259a9c45 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/DateRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/DateRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizer.java index 2205d2c0d..b5c944b44 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/FloatRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/FloatRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/FloatRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/FloatRangeRandomizer.java index af0747660..5b8ef5563 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/FloatRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/FloatRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/InstantRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/InstantRangeRandomizer.java similarity index 85% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/InstantRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/InstantRangeRandomizer.java index 84947d2d4..728fc5c2a 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/InstantRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/InstantRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -65,12 +65,24 @@ protected Instant getDefaultMaxValue() { return Instant.ofEpochMilli(Long.MAX_VALUE); } - @Override - public Instant getRandomValue() { - long minEpochMillis = min.toEpochMilli(); - long maxEpochMillis = max.toEpochMilli(); + @Override + public Instant getRandomValue() { + long minEpochMillis; + long maxEpochMillis; + try { + minEpochMillis = min.toEpochMilli(); + } catch (ArithmeticException ex) { + minEpochMillis = Long.MIN_VALUE; + } + + try { + maxEpochMillis = max.toEpochMilli(); + } catch (ArithmeticException ex) { + maxEpochMillis = Long.MAX_VALUE; + } + long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); - } + } } diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizer.java index b243b1b0e..623544d1d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizer.java index ea212f0b9..b1446b603 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizer.java similarity index 93% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizer.java index 45725ab9f..f5799128b 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -77,10 +77,10 @@ public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); - long seconds = (long) nextDouble(minSeconds, maxSeconds); + long seconds = nextLong(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSeconds = max.getNano(); - long nanoSeconds = (long) nextDouble(minNanoSeconds, maxNanoSeconds); + long nanoSeconds = nextInt(minNanoSeconds, maxNanoSeconds); Instant instant = Instant.ofEpochSecond(seconds, nanoSeconds); return LocalDateTime.ofInstant(instant, ZoneOffset.UTC); diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizer.java similarity index 89% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizer.java index a243b650f..62b7b9649 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -82,10 +82,10 @@ public LocalTime getRandomValue() { int maxMinute = max.getMinute(); int maxHour = max.getHour(); - int randomNanoSecond = (int) nextDouble(minNanoSecond, maxNanoSecond); - int randomSecond = (int) nextDouble(minSecond, maxSecond); - int randomMinute = (int) nextDouble(minMinute, maxMinute); - int randomHour = (int) nextDouble(minHour, maxHour); + int randomNanoSecond = nextInt(minNanoSecond, maxNanoSecond); + int randomSecond = nextInt(minSecond, maxSecond); + int randomMinute = nextInt(minMinute, maxMinute); + int randomHour = nextInt(minHour, maxHour); return LocalTime.of(randomHour, randomMinute, randomSecond, randomNanoSecond); } diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LongRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/LongRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LongRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/LongRangeRandomizer.java index ba6b7c215..ac3726869 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/LongRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/LongRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizer.java similarity index 93% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizer.java index 6a7409b72..e5a79e748 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -75,10 +75,10 @@ protected OffsetDateTime getDefaultMaxValue() { public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); - long seconds = (long) nextDouble(minSeconds, maxSeconds); + long seconds = nextLong(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSeconds = max.getNano(); - long nanoSeconds = (long) nextDouble(minNanoSeconds, maxNanoSeconds); + long nanoSeconds = nextInt(minNanoSeconds, maxNanoSeconds); return OffsetDateTime.ofInstant(Instant.ofEpochSecond(seconds, nanoSeconds), EasyRandomParameters.DEFAULT_DATES_RANGE.getMin().getZone()); } diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizer.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizer.java index 957854801..d1158f42a 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -76,7 +76,7 @@ protected OffsetTime getDefaultMaxValue() { public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); - long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); + long randomSecondOfDay = nextLong(minSecondOfDay, maxSecondOfDay); return OffsetTime.of(LocalTime.ofSecondOfDay(randomSecondOfDay), EasyRandomParameters.DEFAULT_DATES_RANGE.getMin().getOffset()); } diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ShortRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/ShortRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ShortRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/ShortRangeRandomizer.java index 81c16664e..ed1fb5bba 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ShortRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/ShortRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizer.java index bb7b8222c..80b4be94a 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizer.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizer.java index 55f2ae7a3..55037d281 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/YearRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/YearRangeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/YearRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/YearRangeRandomizer.java index ea7843912..25cadc0fe 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/YearRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/YearRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizer.java similarity index 93% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizer.java index ed00b0e7a..4c85b2475 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -75,10 +75,10 @@ protected ZonedDateTime getDefaultMaxValue() { public ZonedDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); - long seconds = (long) nextDouble(minSeconds, maxSeconds); + long seconds = nextLong(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSeconds = max.getNano(); - long nanoSeconds = (long) nextDouble(minNanoSeconds, maxNanoSeconds); + long nanoSeconds = nextInt(minNanoSeconds, maxNanoSeconds); return ZonedDateTime.ofInstant(Instant.ofEpochSecond(seconds, nanoSeconds), min.getZone()); } diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/package-info.java b/src/main/java/org/jeasy/random/randomizers/range/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/range/package-info.java rename to src/main/java/org/jeasy/random/randomizers/range/package-info.java index a98a56396..85e57363d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/range/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/AnnotationRandomizerRegistry.java b/src/main/java/org/jeasy/random/randomizers/registry/AnnotationRandomizerRegistry.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/AnnotationRandomizerRegistry.java rename to src/main/java/org/jeasy/random/randomizers/registry/AnnotationRandomizerRegistry.java index d89104f80..e273d573c 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/AnnotationRandomizerRegistry.java +++ b/src/main/java/org/jeasy/random/randomizers/registry/AnnotationRandomizerRegistry.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/CustomRandomizerRegistry.java b/src/main/java/org/jeasy/random/randomizers/registry/CustomRandomizerRegistry.java similarity index 94% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/CustomRandomizerRegistry.java rename to src/main/java/org/jeasy/random/randomizers/registry/CustomRandomizerRegistry.java index 6fbfddd13..19977330e 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/CustomRandomizerRegistry.java +++ b/src/main/java/org/jeasy/random/randomizers/registry/CustomRandomizerRegistry.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ import org.jeasy.random.util.ReflectionUtils; import java.lang.reflect.Field; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.function.Predicate; @@ -42,8 +42,8 @@ @Priority(-1) public class CustomRandomizerRegistry implements RandomizerRegistry { - private final Map, Randomizer> customFieldRandomizersRegistry = new HashMap<>(); - private final Map, Randomizer> customTypeRandomizersRegistry = new HashMap<>(); + private final Map, Randomizer> customFieldRandomizersRegistry = new LinkedHashMap<>(); + private final Map, Randomizer> customTypeRandomizersRegistry = new LinkedHashMap<>(); @Override public void init(EasyRandomParameters parameters) { diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/ExclusionRandomizerRegistry.java b/src/main/java/org/jeasy/random/randomizers/registry/ExclusionRandomizerRegistry.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/ExclusionRandomizerRegistry.java rename to src/main/java/org/jeasy/random/randomizers/registry/ExclusionRandomizerRegistry.java index d93eb1635..a30a2850c 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/ExclusionRandomizerRegistry.java +++ b/src/main/java/org/jeasy/random/randomizers/registry/ExclusionRandomizerRegistry.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/InternalRandomizerRegistry.java b/src/main/java/org/jeasy/random/randomizers/registry/InternalRandomizerRegistry.java similarity index 91% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/InternalRandomizerRegistry.java rename to src/main/java/org/jeasy/random/randomizers/registry/InternalRandomizerRegistry.java index 4a558f226..ab3e04967 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/InternalRandomizerRegistry.java +++ b/src/main/java/org/jeasy/random/randomizers/registry/InternalRandomizerRegistry.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -56,6 +56,7 @@ import java.util.concurrent.atomic.AtomicLong; import static java.sql.Date.valueOf; +import static org.jeasy.random.util.ConversionUtils.convertDateToLocalDate; /** * Registry for Java built-in types. @@ -93,8 +94,10 @@ public void init(EasyRandomParameters parameters) { randomizers.put(BigDecimal.class, new BigDecimalRandomizer(seed)); randomizers.put(AtomicLong.class, new AtomicLongRandomizer(seed)); randomizers.put(AtomicInteger.class, new AtomicIntegerRandomizer(seed)); - Date minDate = valueOf(parameters.getDateRange().getMin()); - Date maxDate = valueOf(parameters.getDateRange().getMax()); + Date minDate = new Date(Long.MIN_VALUE); + Date maxDate = new Date(Long.MAX_VALUE); + minDate = convertDateToLocalDate(minDate).isAfter(parameters.getDateRange().getMin()) ? minDate : valueOf(parameters.getDateRange().getMin()); + maxDate = convertDateToLocalDate(maxDate).isBefore(parameters.getDateRange().getMax()) ? maxDate : valueOf(parameters.getDateRange().getMax()); randomizers.put(Date.class, new DateRangeRandomizer(minDate, maxDate, seed)); randomizers.put(java.sql.Date.class, new SqlDateRangeRandomizer(new java.sql.Date(minDate.getTime()), new java.sql.Date(maxDate.getTime()), seed)); randomizers.put(java.sql.Time.class, new SqlTimeRandomizer(seed)); diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/TimeRandomizerRegistry.java b/src/main/java/org/jeasy/random/randomizers/registry/TimeRandomizerRegistry.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/TimeRandomizerRegistry.java rename to src/main/java/org/jeasy/random/randomizers/registry/TimeRandomizerRegistry.java index 46baff896..a12d81539 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/TimeRandomizerRegistry.java +++ b/src/main/java/org/jeasy/random/randomizers/registry/TimeRandomizerRegistry.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/package-info.java b/src/main/java/org/jeasy/random/randomizers/registry/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/package-info.java rename to src/main/java/org/jeasy/random/randomizers/registry/package-info.java index 7eea6a9a7..94304930c 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/registry/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/registry/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationWithoutReadMethodBean.java b/src/main/java/org/jeasy/random/randomizers/text/CharSequenceRandomizer.java similarity index 74% rename from easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationWithoutReadMethodBean.java rename to src/main/java/org/jeasy/random/randomizers/text/CharSequenceRandomizer.java index fc106f2e1..354369493 100644 --- a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/BeanValidationWithoutReadMethodBean.java +++ b/src/main/java/org/jeasy/random/randomizers/text/CharSequenceRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,16 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.jeasy.random.validation; +package org.jeasy.random.randomizers.text; -import javax.validation.constraints.NotNull; +import org.jeasy.random.randomizers.AbstractRandomizer; -public class BeanValidationWithoutReadMethodBean { +public abstract class CharSequenceRandomizer extends AbstractRandomizer { - @NotNull - private String fieldWithoutReadMethod; + protected CharSequenceRandomizer() { + super(); + } - public void setFieldWithoutReadMethod(String fieldWithoutReadMethod) { - this.fieldWithoutReadMethod = fieldWithoutReadMethod; + protected CharSequenceRandomizer(long seed) { + super(seed); } -} + +} \ No newline at end of file diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/CharacterRandomizer.java b/src/main/java/org/jeasy/random/randomizers/text/CharacterRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/text/CharacterRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/text/CharacterRandomizer.java index b0fade33f..df5d0bea7 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/CharacterRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/text/CharacterRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizer.java b/src/main/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizer.java index 0691ac0a4..6ae92167f 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/StringRandomizer.java b/src/main/java/org/jeasy/random/randomizers/text/StringRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/text/StringRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/text/StringRandomizer.java index 30b4775f4..0879545ac 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/StringRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/text/StringRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,7 +24,6 @@ package org.jeasy.random.randomizers.text; import org.jeasy.random.EasyRandomParameters; -import org.jeasy.random.randomizers.AbstractRandomizer; import java.nio.charset.Charset; @@ -33,7 +32,7 @@ * * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) */ -public class StringRandomizer extends AbstractRandomizer { +public class StringRandomizer extends CharSequenceRandomizer { private final CharacterRandomizer characterRandomizer; diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/package-info.java b/src/main/java/org/jeasy/random/randomizers/text/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/text/package-info.java rename to src/main/java/org/jeasy/random/randomizers/text/package-info.java index 31fb7e9b8..246ea5429 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/text/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/text/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/CalendarRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/CalendarRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/CalendarRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/CalendarRandomizer.java index d0e2d0485..11ec025eb 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/CalendarRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/CalendarRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DateRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/DateRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DateRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/DateRandomizer.java index 68ef13bdd..a3ec0dea2 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DateRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/DateRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DayRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/DayRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DayRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/DayRandomizer.java index 832d71770..3fc47190b 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DayRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/DayRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DurationRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/DurationRandomizer.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DurationRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/DurationRandomizer.java index 70c85b9e5..0b9f64fac 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/DurationRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/DurationRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/GregorianCalendarRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/GregorianCalendarRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/GregorianCalendarRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/GregorianCalendarRandomizer.java index af464c823..604ade8c7 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/GregorianCalendarRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/GregorianCalendarRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/HourRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/HourRandomizer.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/HourRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/HourRandomizer.java index e331d7fc8..96aedd147 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/HourRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/HourRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,11 +39,11 @@ public class HourRandomizer implements Randomizer { private final IntegerRangeRandomizer hourRandomizer; public HourRandomizer() { - hourRandomizer = new IntegerRangeRandomizer(MIN_HOUR, MAX_HOUR); + hourRandomizer = new IntegerRangeRandomizer(MIN_HOUR, MAX_HOUR + 1); } public HourRandomizer(final long seed) { - hourRandomizer = new IntegerRangeRandomizer(MIN_HOUR, MAX_HOUR, seed); + hourRandomizer = new IntegerRangeRandomizer(MIN_HOUR, MAX_HOUR + 1, seed); } @Override diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/InstantRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/InstantRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/InstantRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/InstantRandomizer.java index 091454336..6bb88f171 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/InstantRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/InstantRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalDateRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/LocalDateRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalDateRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/LocalDateRandomizer.java index a4035e5e4..91f99a12b 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalDateRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/LocalDateRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalDateTimeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/LocalDateTimeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalDateTimeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/LocalDateTimeRandomizer.java index 41c4dedaa..377b6e9cd 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalDateTimeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/LocalDateTimeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalTimeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/LocalTimeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalTimeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/LocalTimeRandomizer.java index 29860f2fa..581f0d8ed 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/LocalTimeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/LocalTimeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/MinuteRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/MinuteRandomizer.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/MinuteRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/MinuteRandomizer.java index 4783c14cc..c743b4e4c 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/MinuteRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/MinuteRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,11 +39,11 @@ public class MinuteRandomizer implements Randomizer { private final IntegerRangeRandomizer minuteRandomizer; public MinuteRandomizer() { - minuteRandomizer = new IntegerRangeRandomizer(MIN_MINUTE, MAX_MINUTE); + minuteRandomizer = new IntegerRangeRandomizer(MIN_MINUTE, MAX_MINUTE + 1); } public MinuteRandomizer(final long seed) { - minuteRandomizer = new IntegerRangeRandomizer(MIN_MINUTE, MAX_MINUTE, seed); + minuteRandomizer = new IntegerRangeRandomizer(MIN_MINUTE, MAX_MINUTE + 1, seed); } @Override diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/MonthDayRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/MonthDayRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/MonthDayRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/MonthDayRandomizer.java index 936d20290..66de869e9 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/MonthDayRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/MonthDayRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/NanoSecondRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/NanoSecondRandomizer.java similarity index 94% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/NanoSecondRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/NanoSecondRandomizer.java index c95387af5..5f7218453 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/NanoSecondRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/NanoSecondRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,11 +40,11 @@ public class NanoSecondRandomizer implements Randomizer { private final IntegerRangeRandomizer nanoSecondRandomizer; public NanoSecondRandomizer() { - nanoSecondRandomizer = new IntegerRangeRandomizer(MIN_NANO_SECOND, MAX_NANO_SECOND); + nanoSecondRandomizer = new IntegerRangeRandomizer(MIN_NANO_SECOND, MAX_NANO_SECOND + 1); } public NanoSecondRandomizer(final long seed) { - nanoSecondRandomizer = new IntegerRangeRandomizer(MIN_NANO_SECOND, MAX_NANO_SECOND, seed); + nanoSecondRandomizer = new IntegerRangeRandomizer(MIN_NANO_SECOND, MAX_NANO_SECOND + 1, seed); } @Override diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/OffsetDateTimeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/OffsetDateTimeRandomizer.java similarity index 98% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/OffsetDateTimeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/OffsetDateTimeRandomizer.java index bc8272d3f..2fb5294fe 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/OffsetDateTimeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/OffsetDateTimeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/OffsetTimeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/OffsetTimeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/OffsetTimeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/OffsetTimeRandomizer.java index 50dce4d52..2f09f968a 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/OffsetTimeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/OffsetTimeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/PeriodRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/PeriodRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/PeriodRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/PeriodRandomizer.java index 5dd5b906d..e2957f9a0 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/PeriodRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/PeriodRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlDateRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/SqlDateRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlDateRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/SqlDateRandomizer.java index 7610b2259..589708873 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlDateRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/SqlDateRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlTimeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/SqlTimeRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlTimeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/SqlTimeRandomizer.java index 4a21c7b95..f7cf2d94c 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlTimeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/SqlTimeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlTimestampRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/SqlTimestampRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlTimestampRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/SqlTimestampRandomizer.java index 65ef51e78..1df122b3f 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/SqlTimestampRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/SqlTimestampRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/TimeZoneRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/TimeZoneRandomizer.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/TimeZoneRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/TimeZoneRandomizer.java index 5bf6e74e7..5ba9e6dbc 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/TimeZoneRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/TimeZoneRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/YearMonthRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/YearMonthRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/YearMonthRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/YearMonthRandomizer.java index 9606ef134..af71f36fa 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/YearMonthRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/YearMonthRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/YearRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/YearRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/YearRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/YearRandomizer.java index a8affe8e6..0dae7c369 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/YearRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/YearRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZoneIdRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/ZoneIdRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZoneIdRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/ZoneIdRandomizer.java index ed2c1e490..11ecfca2a 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZoneIdRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/ZoneIdRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZoneOffsetRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/ZoneOffsetRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZoneOffsetRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/ZoneOffsetRandomizer.java index 3f88e2a99..15ee2d8c8 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZoneOffsetRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/ZoneOffsetRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizer.java b/src/main/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizer.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizer.java rename to src/main/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizer.java index c07c71969..9582125e4 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizer.java +++ b/src/main/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/package-info.java b/src/main/java/org/jeasy/random/randomizers/time/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/randomizers/time/package-info.java rename to src/main/java/org/jeasy/random/randomizers/time/package-info.java index 56b286868..053a7b405 100755 --- a/easy-random-core/src/main/java/org/jeasy/random/randomizers/time/package-info.java +++ b/src/main/java/org/jeasy/random/randomizers/time/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/util/CharacterUtils.java b/src/main/java/org/jeasy/random/util/CharacterUtils.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/util/CharacterUtils.java rename to src/main/java/org/jeasy/random/util/CharacterUtils.java index 5ed38f00c..71d9a7fd2 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/util/CharacterUtils.java +++ b/src/main/java/org/jeasy/random/util/CharacterUtils.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/util/ClassGraphFacade.java b/src/main/java/org/jeasy/random/util/ClassGraphFacade.java similarity index 97% rename from easy-random-core/src/main/java/org/jeasy/random/util/ClassGraphFacade.java rename to src/main/java/org/jeasy/random/util/ClassGraphFacade.java index ef940513e..288156ba9 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/util/ClassGraphFacade.java +++ b/src/main/java/org/jeasy/random/util/ClassGraphFacade.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/util/ConversionUtils.java b/src/main/java/org/jeasy/random/util/ConversionUtils.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/util/ConversionUtils.java rename to src/main/java/org/jeasy/random/util/ConversionUtils.java index ee43d3f62..24a3c8147 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/util/ConversionUtils.java +++ b/src/main/java/org/jeasy/random/util/ConversionUtils.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,10 +26,7 @@ import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.ZoneOffset; +import java.time.*; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.stream.Stream; @@ -67,6 +64,10 @@ public static Object[] convertArguments(final RandomizerArgument[] declaredArgum return arguments; } + public static LocalDate convertDateToLocalDate(Date date) { + return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + } + private static Object convertArray(Object array, Class targetType) { Object[] values = (Object[]) array; Object convertedValuesArray = Array.newInstance(targetType.getComponentType(), values.length); diff --git a/easy-random-core/src/main/java/org/jeasy/random/util/PrimitiveEnum.java b/src/main/java/org/jeasy/random/util/PrimitiveEnum.java similarity index 96% rename from easy-random-core/src/main/java/org/jeasy/random/util/PrimitiveEnum.java rename to src/main/java/org/jeasy/random/util/PrimitiveEnum.java index 9e4a4edde..08825236a 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/util/PrimitiveEnum.java +++ b/src/main/java/org/jeasy/random/util/PrimitiveEnum.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java b/src/main/java/org/jeasy/random/util/ReflectionUtils.java similarity index 91% rename from easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java rename to src/main/java/org/jeasy/random/util/ReflectionUtils.java index c7b078eed..93f74478d 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java +++ b/src/main/java/org/jeasy/random/util/ReflectionUtils.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -96,8 +96,8 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg * @param the actual type to introspect * @return list of declared fields */ - public static List getDeclaredFields(T type) { - return new ArrayList<>(asList(type.getClass().getDeclaredFields())); + public static List getDeclaredFields(Class type) { + return new ArrayList<>(asList(type.getDeclaredFields())); } /** @@ -154,6 +154,29 @@ public static void setFieldValue(final Object object, final Field field, final O field.setAccessible(access); } + /** + * Get a value of a field of a target object. If the target object provides + * a getter for the field, this getter will be used. Otherwise, the field + * will be get using reflection. + * + * @param object instance to get the property value + * @param field field to get the property value + * @throws IllegalAccessException if the property cannot be retrieved + */ + public static Object getProperty(final Object object, final Field field) throws IllegalAccessException { + try { + Optional getter = getReadMethod(field); + if (getter.isPresent()) { + return getter.get().invoke(object); + } else { + return getFieldValue(object, field); + } + } catch (IllegalAccessException | InvocationTargetException e) { + // otherwise, get field using reflection + return getFieldValue(object, field); + } + } + /** * Get the value (accessible or not accessible) of a field of a target object. * @@ -198,7 +221,7 @@ public static boolean isPrimitiveFieldWithDefaultValue(final Object object, fina if (!fieldType.isPrimitive()) { return false; } - Object fieldValue = getFieldValue(object, field); + Object fieldValue = getProperty(object, field); if (fieldValue == null) { return false; } @@ -559,6 +582,30 @@ public static Optional getReadMethod(Field field) { return getPublicMethod("is" + capitalizedFieldName, fieldClass); } + /** + * Get the canonical constructor of a record + * @param recordType the type of the record + * @return the canonical constructor of the record + * @param the generic type of the record + */ + public static Constructor getCanonicalConstructor(Class recordType) { + RecordComponent[] recordComponents = recordType.getRecordComponents(); + Class[] componentTypes = new Class[recordComponents.length]; + for (int i = 0; i < recordComponents.length; i++) { + // recordComponents are ordered, see javadoc: + // "The components are returned in the same order that they are declared in the record header" + componentTypes[i] = recordComponents[i].getType(); + } + try { + return recordType.getDeclaredConstructor(componentTypes); + } catch (NoSuchMethodException e) { + // should not happen, from Record javadoc: + // "A record class has the following mandated members: a public canonical constructor , + // whose descriptor is the same as the record descriptor;" + throw new RuntimeException("Invalid record definition", e); + } + } + private static String capitalize(String propertyName) { return propertyName.substring(0, 1).toUpperCase(ENGLISH) + propertyName.substring(1); } diff --git a/easy-random-core/src/main/java/org/jeasy/random/util/package-info.java b/src/main/java/org/jeasy/random/util/package-info.java similarity index 95% rename from easy-random-core/src/main/java/org/jeasy/random/util/package-info.java rename to src/main/java/org/jeasy/random/util/package-info.java index 80a4aadc6..3faa3eba5 100644 --- a/easy-random-core/src/main/java/org/jeasy/random/util/package-info.java +++ b/src/main/java/org/jeasy/random/util/package-info.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry b/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry similarity index 95% rename from easy-random-core/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry rename to src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry index 357e6fe1b..2d4e47cd9 100644 --- a/easy-random-core/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry +++ b/src/main/resources/META-INF/services/org.jeasy.random.api.RandomizerRegistry @@ -1,7 +1,7 @@ # # The MIT License # -# Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) +# Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/main/resources/easy-random-data.properties b/src/main/resources/easy-random-data.properties similarity index 100% rename from easy-random-core/src/main/resources/easy-random-data.properties rename to src/main/resources/easy-random-data.properties diff --git a/easy-random-core/src/test/java/org/jeasy/random/ArrayPopulatorTest.java b/src/test/java/org/jeasy/random/ArrayPopulatorTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/ArrayPopulatorTest.java rename to src/test/java/org/jeasy/random/ArrayPopulatorTest.java index 9a422a388..39f7f2257 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/ArrayPopulatorTest.java +++ b/src/test/java/org/jeasy/random/ArrayPopulatorTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/ChainedSettersSupportTest.java b/src/test/java/org/jeasy/random/ChainedSettersSupportTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/ChainedSettersSupportTest.java rename to src/test/java/org/jeasy/random/ChainedSettersSupportTest.java index 7f942d4bf..340bcb2d2 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/ChainedSettersSupportTest.java +++ b/src/test/java/org/jeasy/random/ChainedSettersSupportTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/CollectionPopulatorTest.java b/src/test/java/org/jeasy/random/CollectionPopulatorTest.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/CollectionPopulatorTest.java rename to src/test/java/org/jeasy/random/CollectionPopulatorTest.java index 71c5887a7..f6dd32246 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/CollectionPopulatorTest.java +++ b/src/test/java/org/jeasy/random/CollectionPopulatorTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/DefaultExclusionPolicyTest.java b/src/test/java/org/jeasy/random/DefaultExclusionPolicyTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/DefaultExclusionPolicyTest.java rename to src/test/java/org/jeasy/random/DefaultExclusionPolicyTest.java index bc6b34ef6..4370ade5a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/DefaultExclusionPolicyTest.java +++ b/src/test/java/org/jeasy/random/DefaultExclusionPolicyTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/EasyRandomTest.java b/src/test/java/org/jeasy/random/EasyRandomTest.java similarity index 89% rename from easy-random-core/src/test/java/org/jeasy/random/EasyRandomTest.java rename to src/test/java/org/jeasy/random/EasyRandomTest.java index 7011e0f5a..8b9a9de8f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/EasyRandomTest.java +++ b/src/test/java/org/jeasy/random/EasyRandomTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,6 +33,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import java.io.Serializable; import java.lang.reflect.Modifier; import java.util.*; import java.util.stream.Stream; @@ -231,6 +232,7 @@ void nextEnumShouldNotAlwaysReturnTheSameValue() { } @Test + @Disabled("https://github.com/j-easy/easy-random/issues/494") void fieldsOfTypeClassShouldBeSkipped() { try { TestBean testBean = easyRandom.nextObject(TestBean.class); @@ -240,7 +242,7 @@ void fieldsOfTypeClassShouldBeSkipped() { fail("Should skip fields of type Class"); } } - + @Test void differentCollectionsShouldBeRandomizedWithDifferentSizes() { // given @@ -248,10 +250,10 @@ class Foo { List names; List addresses; } - + // when Foo foo = new EasyRandom().nextObject(Foo.class); - + // then assertThat(foo.names.size()).isNotEqualTo(foo.addresses.size()); } @@ -278,10 +280,10 @@ class Base { T t; } class Concrete extends Base {} - + // when Concrete concrete = easyRandom.nextObject(Concrete.class); - + // then assertThat(concrete.t).isInstanceOf(String.class); assertThat(concrete.t).isNotEmpty(); @@ -295,10 +297,10 @@ class Base { S s; } class Concrete extends Base {} - + // when Concrete concrete = easyRandom.nextObject(Concrete.class); - + // then assertThat(concrete.t).isInstanceOf(String.class); assertThat(concrete.s).isInstanceOf(Long.class); @@ -324,7 +326,7 @@ public String getY() { // when Concrete concrete = easyRandom.nextObject(Concrete.class); - + // then assertThat(concrete.getX().getClass()).isEqualTo(Integer.class); assertThat(concrete.getY().getClass()).isEqualTo(String.class); @@ -348,7 +350,7 @@ public String getY() { // when Concrete concrete = easyRandom.nextObject(Concrete.class); - + // then assertThat(concrete.getX().getClass()).isEqualTo(Street.class); assertThat(concrete.getY().getClass()).isEqualTo(String.class); @@ -372,7 +374,7 @@ public String getY() { // when Concrete concrete = easyRandom.nextObject(Concrete.class); - + // then assertThat(concrete.getX().getClass()).isEqualTo(BoundedBaseClass.IntWrapper.class); assertThat(concrete.getY().getClass()).isEqualTo(String.class); @@ -410,7 +412,7 @@ class Concrete extends GenericBaseClass { // when Concrete concrete = easyRandom.nextObject(Concrete.class); - + // then assertThat(concrete.getX()).isInstanceOf(String.class); assertThat(concrete.getY()).isInstanceOf(Long.class); @@ -462,6 +464,79 @@ class Concrete extends GenericBaseClass { assertThat(concrete.getX()).isInstanceOf(String.class); } + //https://github.com/j-easy/easy-random/issues/443 + @Test + void shouldRandomizeMultipleGenericIntermediateTypes() { + // given + class Base { + T t; + S s; + } + + class Intermediate extends Base { } + + class Concrete extends Intermediate { } + + // when + Concrete actual = easyRandom.nextObject(Concrete.class); + + // then + assertThat(actual.t).isInstanceOf(String.class); + assertThat(actual.s).isInstanceOf(Long.class); + } + + // https://github.com/j-easy/easy-random/issues/441 + @Test + void genericComposedShouldBeCorrectlyPopulated() { + // given + abstract class IdResource> { + + private K id; + + @SuppressWarnings("unchecked") + public T setId(K id) { + this.id = id; + return (T) this; + } + + public K getId() { + return id; + } + } + + class LongResource extends IdResource { + } + + class CompositeResource { + private LongResource longResource; + } + EasyRandom easyRandom = new EasyRandom(); + + // when + CompositeResource composite = easyRandom.nextObject(CompositeResource.class); + + // then + assertThat(composite.longResource.getId()) + .isInstanceOf(Long.class); + } + + @Test + void testGenericFieldRandomization() { + // given + class Base { + T t; + } + class Concrete { + Base f; + } + + // when + Concrete concrete = easyRandom.nextObject(Concrete.class); + + // then + assertThat(concrete.f).isInstanceOf(Base.class); + } + private void validatePerson(final Person person) { assertThat(person).isNotNull(); assertThat(person.getEmail()).isNotEmpty(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/FieldExclusionTest.java b/src/test/java/org/jeasy/random/FieldExclusionTest.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/FieldExclusionTest.java rename to src/test/java/org/jeasy/random/FieldExclusionTest.java index 826a31369..e2dc5362a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/FieldExclusionTest.java +++ b/src/test/java/org/jeasy/random/FieldExclusionTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/FieldNameMatchingWithRegex.java b/src/test/java/org/jeasy/random/FieldNameMatchingWithRegex.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/FieldNameMatchingWithRegex.java rename to src/test/java/org/jeasy/random/FieldNameMatchingWithRegex.java index d98ee2872..edfafcc5f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/FieldNameMatchingWithRegex.java +++ b/src/test/java/org/jeasy/random/FieldNameMatchingWithRegex.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/FieldPopulatorTest.java b/src/test/java/org/jeasy/random/FieldPopulatorTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/FieldPopulatorTest.java rename to src/test/java/org/jeasy/random/FieldPopulatorTest.java index de3a6dd61..eb7e03ca4 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/FieldPopulatorTest.java +++ b/src/test/java/org/jeasy/random/FieldPopulatorTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -183,7 +183,9 @@ void whenRandomizationDepthIsExceeded_thenFieldsAreNotInitialized() throws Excep // Given Field name = Human.class.getDeclaredField("name"); Human human = new Human(); + EasyRandomParameters parameters = new EasyRandomParameters().randomizationDepth(5); RandomizationContext context = Mockito.mock(RandomizationContext.class); + when(context.getParameters()).thenReturn(parameters); when(context.hasExceededRandomizationDepth()).thenReturn(true); // When diff --git a/easy-random-core/src/test/java/org/jeasy/random/MapPopulatorTest.java b/src/test/java/org/jeasy/random/MapPopulatorTest.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/MapPopulatorTest.java rename to src/test/java/org/jeasy/random/MapPopulatorTest.java index 112336be9..d5b924472 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/MapPopulatorTest.java +++ b/src/test/java/org/jeasy/random/MapPopulatorTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/ObjenesisObjectFactoryTest.java b/src/test/java/org/jeasy/random/ObjenesisObjectFactoryTest.java similarity index 86% rename from easy-random-core/src/test/java/org/jeasy/random/ObjenesisObjectFactoryTest.java rename to src/test/java/org/jeasy/random/ObjenesisObjectFactoryTest.java index 5d2c37efe..0d5f688c2 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/ObjenesisObjectFactoryTest.java +++ b/src/test/java/org/jeasy/random/ObjenesisObjectFactoryTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,9 +38,6 @@ @ExtendWith(MockitoExtension.class) class ObjenesisObjectFactoryTest { - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private RandomizerContext context; - private ObjenesisObjectFactory objenesisObjectFactory; @BeforeEach @@ -50,6 +47,7 @@ void setUp() { @Test void concreteClassesShouldBeCreatedAsExpected() { + RandomizerContext context = new RandomizationContext(String.class, new EasyRandomParameters()); String string = objenesisObjectFactory.createInstance(String.class, context); assertThat(string).isNotNull(); @@ -57,7 +55,8 @@ void concreteClassesShouldBeCreatedAsExpected() { @Test void whenNoConcreteTypeIsFound_thenShouldThrowAnInstantiationError() { - Mockito.when(context.getParameters().isScanClasspathForConcreteTypes()).thenReturn(true); + EasyRandomParameters parameters = new EasyRandomParameters().scanClasspathForConcreteTypes(true); + RandomizerContext context = new RandomizationContext(AbstractFoo.class, parameters); assertThatThrownBy(() -> objenesisObjectFactory.createInstance(AbstractFoo.class, context)).isInstanceOf(InstantiationError.class); } diff --git a/easy-random-core/src/test/java/org/jeasy/random/OptionalPopulatorTest.java b/src/test/java/org/jeasy/random/OptionalPopulatorTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/OptionalPopulatorTest.java rename to src/test/java/org/jeasy/random/OptionalPopulatorTest.java index b87ae3674..7735c3a00 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/OptionalPopulatorTest.java +++ b/src/test/java/org/jeasy/random/OptionalPopulatorTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/PriorityComparatorTest.java b/src/test/java/org/jeasy/random/PriorityComparatorTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/PriorityComparatorTest.java rename to src/test/java/org/jeasy/random/PriorityComparatorTest.java index 5b4333811..0d48593b9 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/PriorityComparatorTest.java +++ b/src/test/java/org/jeasy/random/PriorityComparatorTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/RandomizationContextTest.java b/src/test/java/org/jeasy/random/RandomizationContextTest.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/RandomizationContextTest.java rename to src/test/java/org/jeasy/random/RandomizationContextTest.java index ac2ab2403..07dc8dda5 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/RandomizationContextTest.java +++ b/src/test/java/org/jeasy/random/RandomizationContextTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/RandomizerAnnotationTest.java b/src/test/java/org/jeasy/random/RandomizerAnnotationTest.java similarity index 82% rename from easy-random-core/src/test/java/org/jeasy/random/RandomizerAnnotationTest.java rename to src/test/java/org/jeasy/random/RandomizerAnnotationTest.java index b1097c597..6ba26e858 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/RandomizerAnnotationTest.java +++ b/src/test/java/org/jeasy/random/RandomizerAnnotationTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -55,25 +55,6 @@ void testRandomizerArgumentAsArray() { assertThat(person.getAge()).isIn(1, 2, 3); } - - @Test - void testRandomizerIsReused() { - MyStringRandomizer.resetNumConstructorCalled(); - - EasyRandom easyRandom = new EasyRandom(); - - Person firstRandomPerson = easyRandom.nextObject(Person.class); - Person secondRandomPerson = easyRandom.nextObject(Person.class); - - // If the randomizer would not be reused, then - - // The names would be equal, since the seed of MyStringRandomizer is a constant - assertThat(firstRandomPerson.getName()).isNotEqualTo(secondRandomPerson.getName()); - - // The constructor would have been called multiple times - assertThat(MyStringRandomizer.getNumConstructorCalled()).isEqualTo(1); - } - static class Person { @org.jeasy.random.annotation.Randomizer(value = MyStringRandomizer.class, args = { @@ -110,12 +91,10 @@ public void setAge(int age) { public static class MyStringRandomizer extends AbstractRandomizer { private String[] words; - private static int numConstructorCalled = 0; public MyStringRandomizer(final long seed, String[] words) { super(seed); this.words = words; - numConstructorCalled += 1; } @Override @@ -124,13 +103,6 @@ public String getRandomValue() { return words[randomIndex]; } - static int getNumConstructorCalled() { - return numConstructorCalled; - } - - static void resetNumConstructorCalled() { - numConstructorCalled = 0; - } } public static class MyNumbersRandomizer extends AbstractRandomizer { diff --git a/easy-random-core/src/test/java/org/jeasy/random/RandomizerProxyTest.java b/src/test/java/org/jeasy/random/RandomizerProxyTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/RandomizerProxyTest.java rename to src/test/java/org/jeasy/random/RandomizerProxyTest.java index 275f12f4c..d556693ab 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/RandomizerProxyTest.java +++ b/src/test/java/org/jeasy/random/RandomizerProxyTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/test/java/org/jeasy/random/RecordCreationTest.java b/src/test/java/org/jeasy/random/RecordCreationTest.java new file mode 100644 index 000000000..b4221193a --- /dev/null +++ b/src/test/java/org/jeasy/random/RecordCreationTest.java @@ -0,0 +1,173 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random; + +import org.assertj.core.api.Assertions; +import org.jeasy.random.records.CityRegistryEntry; +import org.jeasy.random.records.CargoBay; +import org.jeasy.random.records.CommandConsole; +import org.jeasy.random.records.Dog; +import org.jeasy.random.records.DogOwner; +import org.jeasy.random.records.ExpeditionManifest; +import org.jeasy.random.records.ExpeditionVehicle; +import org.jeasy.random.records.IdentityCard; +import org.jeasy.random.records.LaunchBay; +import org.jeasy.random.records.ManifestReference; +import org.jeasy.random.records.MissionCommander; +import org.jeasy.random.records.NationalIdentityCard; +import org.jeasy.random.records.Person; +import org.jeasy.random.records.ResearchAirship; +import org.jeasy.random.records.ResidentProfile; +import org.jeasy.random.records.ResidentArchiveEntry; +import org.jeasy.random.records.ResidentDocument; +import org.jeasy.random.records.Rottweiler; +import org.junit.jupiter.api.Test; + +public class RecordCreationTest { + + @Test + void testRandomRecordCreation() { + // given + EasyRandom easyRandom = new EasyRandom(); + + // when + Person person = easyRandom.nextObject(Person.class); + + // then + Assertions.assertThat(person).isNotNull(); + Assertions.assertThat(person.id()).isNotNull(); + Assertions.assertThat(person.name()).isNotNull(); + } + + @Test + void testRandomRecordCreationWithRecordComponent() { + // given + EasyRandomParameters easyRandomParameters = new EasyRandomParameters() + .scanClasspathForConcreteTypes(true); + EasyRandom easyRandom = new EasyRandom(easyRandomParameters); + + // when + DogOwner dogOwner = easyRandom.nextObject(DogOwner.class); + + // then + Assertions.assertThat(dogOwner).isNotNull(); + Assertions.assertThat(dogOwner.ownerName()).isNotNull(); + Dog dog = dogOwner.dog(); + Assertions.assertThat(dog).isNotNull(); + Assertions.assertThat(dog).isInstanceOf(Rottweiler.class); + Rottweiler rottweiler = (Rottweiler) dog; + Assertions.assertThat(rottweiler.name()).isNotNull(); + } + + @Test + void testRandomRecordCreationWithThreeLevelsOfRecordComponents() { + // given + EasyRandom easyRandom = new EasyRandom(); + + // when + CityRegistryEntry cityRegistryEntry = easyRandom.nextObject(CityRegistryEntry.class); + + // then + Assertions.assertThat(cityRegistryEntry).isNotNull(); + Assertions.assertThat(cityRegistryEntry.registryId()).isNotNull(); + ResidentProfile residentProfile = cityRegistryEntry.residentProfile(); + Assertions.assertThat(residentProfile).isNotNull(); + Assertions.assertThat(residentProfile.city()).isNotNull(); + IdentityCard identityCard = residentProfile.identityCard(); + Assertions.assertThat(identityCard).isNotNull(); + Assertions.assertThat(identityCard.documentNumber()).isNotNull(); + Person person = identityCard.person(); + Assertions.assertThat(person).isNotNull(); + Assertions.assertThat(person.id()).isNotNull(); + Assertions.assertThat(person.name()).isNotNull(); + } + + @Test + void testRandomRecordCreationWithInterfaceRecordComponent() { + // given + EasyRandomParameters easyRandomParameters = new EasyRandomParameters() + .scanClasspathForConcreteTypes(true); + EasyRandom easyRandom = new EasyRandom(easyRandomParameters); + + // when + ResidentArchiveEntry residentArchiveEntry = easyRandom.nextObject(ResidentArchiveEntry.class); + + // then + Assertions.assertThat(residentArchiveEntry).isNotNull(); + Assertions.assertThat(residentArchiveEntry.archiveId()).isNotNull(); + ResidentDocument residentDocument = residentArchiveEntry.residentDocument(); + Assertions.assertThat(residentDocument).isNotNull(); + Assertions.assertThat(residentDocument).isInstanceOf(NationalIdentityCard.class); + NationalIdentityCard nationalIdentityCard = (NationalIdentityCard) residentDocument; + Assertions.assertThat(nationalIdentityCard.referenceNumber()).isNotNull(); + Person person = nationalIdentityCard.person(); + Assertions.assertThat(person).isNotNull(); + Assertions.assertThat(person.id()).isNotNull(); + Assertions.assertThat(person.name()).isNotNull(); + } + + @Test + void testRandomRecordCreationWithMixedHierarchy() { + // given + EasyRandomParameters easyRandomParameters = new EasyRandomParameters() + .scanClasspathForConcreteTypes(true); + EasyRandom easyRandom = new EasyRandom(easyRandomParameters); + + // when + ExpeditionManifest expeditionManifest = easyRandom.nextObject(ExpeditionManifest.class); + + // then + Assertions.assertThat(expeditionManifest).isNotNull(); + ManifestReference manifestReference = expeditionManifest.manifestReference(); + Assertions.assertThat(manifestReference).isNotNull(); + Assertions.assertThat(manifestReference.manifestCode()).isNotNull(); + Assertions.assertThat(manifestReference.departureZone()).isNotNull(); + Assertions.assertThat(manifestReference.priorityLabel()).isNotNull(); + ExpeditionVehicle expeditionVehicle = expeditionManifest.expeditionVehicle(); + Assertions.assertThat(expeditionVehicle).isNotNull(); + Assertions.assertThat(expeditionVehicle).isInstanceOf(ResearchAirship.class); + ResearchAirship researchAirship = (ResearchAirship) expeditionVehicle; + Assertions.assertThat(researchAirship.vehicleName()).isNotNull(); + LaunchBay launchBay = researchAirship.launchBay(); + Assertions.assertThat(launchBay).isNotNull(); + Assertions.assertThat(launchBay.bayCode()).isNotNull(); + Assertions.assertThat(launchBay.weatherWindow()).isNotNull(); + Assertions.assertThat(launchBay.accessBadge()).isNotNull(); + CargoBay cargoBay = researchAirship.cargoBay(); + Assertions.assertThat(cargoBay).isNotNull(); + Assertions.assertThat(cargoBay.cargoCode()).isNotNull(); + Assertions.assertThat(cargoBay.supplyCrate()).isNotNull(); + Assertions.assertThat(cargoBay.cargoInspector()).isNotNull(); + MissionCommander missionCommander = expeditionManifest.missionCommander(); + Assertions.assertThat(missionCommander).isNotNull(); + Assertions.assertThat(missionCommander.getCommanderName()).isNotNull(); + Assertions.assertThat(missionCommander.getRank()).isNotNull(); + CommandConsole commandConsole = missionCommander.getCommandConsole(); + Assertions.assertThat(commandConsole).isNotNull(); + Assertions.assertThat(commandConsole.getConsoleId()).isNotNull(); + Assertions.assertThat(commandConsole.getWeatherWindow()).isNotNull(); + Assertions.assertThat(commandConsole.getAccessBadge()).isNotNull(); + } + +} diff --git a/easy-random-core/src/test/java/org/jeasy/random/RegistriesRandomizerProviderTest.java b/src/test/java/org/jeasy/random/RegistriesRandomizerProviderTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/RegistriesRandomizerProviderTest.java rename to src/test/java/org/jeasy/random/RegistriesRandomizerProviderTest.java index 51097736b..f9b376d18 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/RegistriesRandomizerProviderTest.java +++ b/src/test/java/org/jeasy/random/RegistriesRandomizerProviderTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/RepeatableRandomTest.java b/src/test/java/org/jeasy/random/RepeatableRandomTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/RepeatableRandomTest.java rename to src/test/java/org/jeasy/random/RepeatableRandomTest.java index b74e37e96..4639f8712 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/RepeatableRandomTest.java +++ b/src/test/java/org/jeasy/random/RepeatableRandomTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/TypeExclusionTest.java b/src/test/java/org/jeasy/random/TypeExclusionTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/TypeExclusionTest.java rename to src/test/java/org/jeasy/random/TypeExclusionTest.java index 0022e9552..3307d0600 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/TypeExclusionTest.java +++ b/src/test/java/org/jeasy/random/TypeExclusionTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/AbstractBean.java b/src/test/java/org/jeasy/random/beans/AbstractBean.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/AbstractBean.java rename to src/test/java/org/jeasy/random/beans/AbstractBean.java index 48c00ec65..df3cd1ec2 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/AbstractBean.java +++ b/src/test/java/org/jeasy/random/beans/AbstractBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/AbstractEnum.java b/src/test/java/org/jeasy/random/beans/AbstractEnum.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/AbstractEnum.java rename to src/test/java/org/jeasy/random/beans/AbstractEnum.java index b42883b72..62b5e4e0f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/AbstractEnum.java +++ b/src/test/java/org/jeasy/random/beans/AbstractEnum.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Address.java b/src/test/java/org/jeasy/random/beans/Address.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Address.java rename to src/test/java/org/jeasy/random/beans/Address.java index e8fef07f4..c9414c0e2 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Address.java +++ b/src/test/java/org/jeasy/random/beans/Address.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Ape.java b/src/test/java/org/jeasy/random/beans/Ape.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Ape.java rename to src/test/java/org/jeasy/random/beans/Ape.java index b38f172f8..3e83053da 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Ape.java +++ b/src/test/java/org/jeasy/random/beans/Ape.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/ArrayBean.java b/src/test/java/org/jeasy/random/beans/ArrayBean.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/beans/ArrayBean.java rename to src/test/java/org/jeasy/random/beans/ArrayBean.java index db0d110ca..05f0eff3d 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/ArrayBean.java +++ b/src/test/java/org/jeasy/random/beans/ArrayBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Bar.java b/src/test/java/org/jeasy/random/beans/Bar.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Bar.java rename to src/test/java/org/jeasy/random/beans/Bar.java index d7af305f7..b99055703 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Bar.java +++ b/src/test/java/org/jeasy/random/beans/Bar.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/BeanWithDefaultFieldValues.java b/src/test/java/org/jeasy/random/beans/BeanWithDefaultFieldValues.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/BeanWithDefaultFieldValues.java rename to src/test/java/org/jeasy/random/beans/BeanWithDefaultFieldValues.java index 04a3bb9a9..220b0ea1b 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/BeanWithDefaultFieldValues.java +++ b/src/test/java/org/jeasy/random/beans/BeanWithDefaultFieldValues.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/BoundedBaseClass.java b/src/test/java/org/jeasy/random/beans/BoundedBaseClass.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/BoundedBaseClass.java rename to src/test/java/org/jeasy/random/beans/BoundedBaseClass.java index 22525abc8..a9856a25b 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/BoundedBaseClass.java +++ b/src/test/java/org/jeasy/random/beans/BoundedBaseClass.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/ChainedSetterBean.java b/src/test/java/org/jeasy/random/beans/ChainedSetterBean.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/ChainedSetterBean.java rename to src/test/java/org/jeasy/random/beans/ChainedSetterBean.java index 38932edb9..b4dacbbe2 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/ChainedSetterBean.java +++ b/src/test/java/org/jeasy/random/beans/ChainedSetterBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/ClassUsingAbstractEnum.java b/src/test/java/org/jeasy/random/beans/ClassUsingAbstractEnum.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/ClassUsingAbstractEnum.java rename to src/test/java/org/jeasy/random/beans/ClassUsingAbstractEnum.java index cbb9d05f7..bcdbbe9e5 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/ClassUsingAbstractEnum.java +++ b/src/test/java/org/jeasy/random/beans/ClassUsingAbstractEnum.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/CollectionBean.java b/src/test/java/org/jeasy/random/beans/CollectionBean.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/beans/CollectionBean.java rename to src/test/java/org/jeasy/random/beans/CollectionBean.java index 2a851964a..4a2bee940 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/CollectionBean.java +++ b/src/test/java/org/jeasy/random/beans/CollectionBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/ComparableBean.java b/src/test/java/org/jeasy/random/beans/ComparableBean.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/ComparableBean.java rename to src/test/java/org/jeasy/random/beans/ComparableBean.java index f38954956..50476dc74 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/ComparableBean.java +++ b/src/test/java/org/jeasy/random/beans/ComparableBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/CompositeCollectionBean.java b/src/test/java/org/jeasy/random/beans/CompositeCollectionBean.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/beans/CompositeCollectionBean.java rename to src/test/java/org/jeasy/random/beans/CompositeCollectionBean.java index 5b80a148f..e584fdba6 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/CompositeCollectionBean.java +++ b/src/test/java/org/jeasy/random/beans/CompositeCollectionBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/CompositeMapBean.java b/src/test/java/org/jeasy/random/beans/CompositeMapBean.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/beans/CompositeMapBean.java rename to src/test/java/org/jeasy/random/beans/CompositeMapBean.java index 357fd6cb6..ea1b24c48 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/CompositeMapBean.java +++ b/src/test/java/org/jeasy/random/beans/CompositeMapBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/ConcreteBar.java b/src/test/java/org/jeasy/random/beans/ConcreteBar.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/ConcreteBar.java rename to src/test/java/org/jeasy/random/beans/ConcreteBar.java index f51ad6521..9e269cc0a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/ConcreteBar.java +++ b/src/test/java/org/jeasy/random/beans/ConcreteBar.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/CustomList.java b/src/test/java/org/jeasy/random/beans/CustomList.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/beans/CustomList.java rename to src/test/java/org/jeasy/random/beans/CustomList.java index e0027e25e..76c0f258b 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/CustomList.java +++ b/src/test/java/org/jeasy/random/beans/CustomList.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/CustomMap.java b/src/test/java/org/jeasy/random/beans/CustomMap.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/beans/CustomMap.java rename to src/test/java/org/jeasy/random/beans/CustomMap.java index 46a0128b9..a98a1e148 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/CustomMap.java +++ b/src/test/java/org/jeasy/random/beans/CustomMap.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/DelayedQueueBean.java b/src/test/java/org/jeasy/random/beans/DelayedQueueBean.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/beans/DelayedQueueBean.java rename to src/test/java/org/jeasy/random/beans/DelayedQueueBean.java index 47d7c858f..1ba693f32 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/DelayedQueueBean.java +++ b/src/test/java/org/jeasy/random/beans/DelayedQueueBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/EnumMapBean.java b/src/test/java/org/jeasy/random/beans/EnumMapBean.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/EnumMapBean.java rename to src/test/java/org/jeasy/random/beans/EnumMapBean.java index 510324893..88cb36dbf 100755 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/EnumMapBean.java +++ b/src/test/java/org/jeasy/random/beans/EnumMapBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Foo.java b/src/test/java/org/jeasy/random/beans/Foo.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Foo.java rename to src/test/java/org/jeasy/random/beans/Foo.java index 3acaa87dd..6235ad26a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Foo.java +++ b/src/test/java/org/jeasy/random/beans/Foo.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Gender.java b/src/test/java/org/jeasy/random/beans/Gender.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Gender.java rename to src/test/java/org/jeasy/random/beans/Gender.java index 960dcfff0..545568296 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Gender.java +++ b/src/test/java/org/jeasy/random/beans/Gender.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/GenericBaseClass.java b/src/test/java/org/jeasy/random/beans/GenericBaseClass.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/GenericBaseClass.java rename to src/test/java/org/jeasy/random/beans/GenericBaseClass.java index 5bb16da75..a5345cdae 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/GenericBaseClass.java +++ b/src/test/java/org/jeasy/random/beans/GenericBaseClass.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/GenericBaseClass2.java b/src/test/java/org/jeasy/random/beans/GenericBaseClass2.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/GenericBaseClass2.java rename to src/test/java/org/jeasy/random/beans/GenericBaseClass2.java index a86346e60..e25957161 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/GenericBaseClass2.java +++ b/src/test/java/org/jeasy/random/beans/GenericBaseClass2.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Human.java b/src/test/java/org/jeasy/random/beans/Human.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Human.java rename to src/test/java/org/jeasy/random/beans/Human.java index dd717a08b..cfe8e0e72 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Human.java +++ b/src/test/java/org/jeasy/random/beans/Human.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/ImmutableBean.java b/src/test/java/org/jeasy/random/beans/ImmutableBean.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/ImmutableBean.java rename to src/test/java/org/jeasy/random/beans/ImmutableBean.java index 9c7759593..de015038c 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/ImmutableBean.java +++ b/src/test/java/org/jeasy/random/beans/ImmutableBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Mamals.java b/src/test/java/org/jeasy/random/beans/Mamals.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Mamals.java rename to src/test/java/org/jeasy/random/beans/Mamals.java index 74ca86e26..a23e215d2 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Mamals.java +++ b/src/test/java/org/jeasy/random/beans/Mamals.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Mammal.java b/src/test/java/org/jeasy/random/beans/Mammal.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Mammal.java rename to src/test/java/org/jeasy/random/beans/Mammal.java index b107b5532..772a13584 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Mammal.java +++ b/src/test/java/org/jeasy/random/beans/Mammal.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/MammalImpl.java b/src/test/java/org/jeasy/random/beans/MammalImpl.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/MammalImpl.java rename to src/test/java/org/jeasy/random/beans/MammalImpl.java index ac8cd127f..c70b59967 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/MammalImpl.java +++ b/src/test/java/org/jeasy/random/beans/MammalImpl.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/MapBean.java b/src/test/java/org/jeasy/random/beans/MapBean.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/beans/MapBean.java rename to src/test/java/org/jeasy/random/beans/MapBean.java index e8b734842..e3821ec92 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/MapBean.java +++ b/src/test/java/org/jeasy/random/beans/MapBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Node.java b/src/test/java/org/jeasy/random/beans/Node.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Node.java rename to src/test/java/org/jeasy/random/beans/Node.java index 85e7826e8..c88c7ed03 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Node.java +++ b/src/test/java/org/jeasy/random/beans/Node.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Person.java b/src/test/java/org/jeasy/random/beans/Person.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Person.java rename to src/test/java/org/jeasy/random/beans/Person.java index 4302a9aad..e773e934f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Person.java +++ b/src/test/java/org/jeasy/random/beans/Person.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/PersonTuple.java b/src/test/java/org/jeasy/random/beans/PersonTuple.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/PersonTuple.java rename to src/test/java/org/jeasy/random/beans/PersonTuple.java index 94d86321b..893e02bc3 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/PersonTuple.java +++ b/src/test/java/org/jeasy/random/beans/PersonTuple.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Salary.java b/src/test/java/org/jeasy/random/beans/Salary.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Salary.java rename to src/test/java/org/jeasy/random/beans/Salary.java index c3c8ff29c..38285cffc 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Salary.java +++ b/src/test/java/org/jeasy/random/beans/Salary.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/SocialPerson.java b/src/test/java/org/jeasy/random/beans/SocialPerson.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/SocialPerson.java rename to src/test/java/org/jeasy/random/beans/SocialPerson.java index 45b1c6ed3..cbe3aa72c 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/SocialPerson.java +++ b/src/test/java/org/jeasy/random/beans/SocialPerson.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Street.java b/src/test/java/org/jeasy/random/beans/Street.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Street.java rename to src/test/java/org/jeasy/random/beans/Street.java index 92e2a5209..1c816725a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Street.java +++ b/src/test/java/org/jeasy/random/beans/Street.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/SynchronousQueueBean.java b/src/test/java/org/jeasy/random/beans/SynchronousQueueBean.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/SynchronousQueueBean.java rename to src/test/java/org/jeasy/random/beans/SynchronousQueueBean.java index 05ed73b19..dc5203fe7 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/SynchronousQueueBean.java +++ b/src/test/java/org/jeasy/random/beans/SynchronousQueueBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/TestBean.java b/src/test/java/org/jeasy/random/beans/TestBean.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/TestBean.java rename to src/test/java/org/jeasy/random/beans/TestBean.java index 0e30d13bd..699462d3d 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/TestBean.java +++ b/src/test/java/org/jeasy/random/beans/TestBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/TestData.java b/src/test/java/org/jeasy/random/beans/TestData.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/beans/TestData.java rename to src/test/java/org/jeasy/random/beans/TestData.java index 03e1eb5f1..53a33c376 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/TestData.java +++ b/src/test/java/org/jeasy/random/beans/TestData.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/TestEnum.java b/src/test/java/org/jeasy/random/beans/TestEnum.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/TestEnum.java rename to src/test/java/org/jeasy/random/beans/TestEnum.java index 8ebf1cca7..edc76642a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/TestEnum.java +++ b/src/test/java/org/jeasy/random/beans/TestEnum.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/TimeBean.java b/src/test/java/org/jeasy/random/beans/TimeBean.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/beans/TimeBean.java rename to src/test/java/org/jeasy/random/beans/TimeBean.java index f416835db..d86e67420 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/TimeBean.java +++ b/src/test/java/org/jeasy/random/beans/TimeBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/TypeVariableCollectionBean.java b/src/test/java/org/jeasy/random/beans/TypeVariableCollectionBean.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/TypeVariableCollectionBean.java rename to src/test/java/org/jeasy/random/beans/TypeVariableCollectionBean.java index 9d943d5a1..05df4d31d 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/TypeVariableCollectionBean.java +++ b/src/test/java/org/jeasy/random/beans/TypeVariableCollectionBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/Website.java b/src/test/java/org/jeasy/random/beans/Website.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/Website.java rename to src/test/java/org/jeasy/random/beans/Website.java index 577de12c2..905a67422 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/Website.java +++ b/src/test/java/org/jeasy/random/beans/Website.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/WildCardCollectionBean.java b/src/test/java/org/jeasy/random/beans/WildCardCollectionBean.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/beans/WildCardCollectionBean.java rename to src/test/java/org/jeasy/random/beans/WildCardCollectionBean.java index 5d5d807b5..79b52a216 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/WildCardCollectionBean.java +++ b/src/test/java/org/jeasy/random/beans/WildCardCollectionBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/WildCardMapBean.java b/src/test/java/org/jeasy/random/beans/WildCardMapBean.java similarity index 99% rename from easy-random-core/src/test/java/org/jeasy/random/beans/WildCardMapBean.java rename to src/test/java/org/jeasy/random/beans/WildCardMapBean.java index af30ec0cf..f9219fbcc 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/WildCardMapBean.java +++ b/src/test/java/org/jeasy/random/beans/WildCardMapBean.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/A.java b/src/test/java/org/jeasy/random/beans/exclusion/A.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/A.java rename to src/test/java/org/jeasy/random/beans/exclusion/A.java index 933f60ae9..14a3da3ca 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/A.java +++ b/src/test/java/org/jeasy/random/beans/exclusion/A.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/B.java b/src/test/java/org/jeasy/random/beans/exclusion/B.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/B.java rename to src/test/java/org/jeasy/random/beans/exclusion/B.java index 163d87be8..7c839b279 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/B.java +++ b/src/test/java/org/jeasy/random/beans/exclusion/B.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/C.java b/src/test/java/org/jeasy/random/beans/exclusion/C.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/C.java rename to src/test/java/org/jeasy/random/beans/exclusion/C.java index 26ce697f4..bda78bfc2 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/beans/exclusion/C.java +++ b/src/test/java/org/jeasy/random/beans/exclusion/C.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/City.java b/src/test/java/org/jeasy/random/context/City.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/context/City.java rename to src/test/java/org/jeasy/random/context/City.java index 81524fcc6..d69664bff 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/City.java +++ b/src/test/java/org/jeasy/random/context/City.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/CityRandomizer.java b/src/test/java/org/jeasy/random/context/CityRandomizer.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/context/CityRandomizer.java rename to src/test/java/org/jeasy/random/context/CityRandomizer.java index 9e2b209c5..8b6c3be1e 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/CityRandomizer.java +++ b/src/test/java/org/jeasy/random/context/CityRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/ContextAwareRandomizationTests.java b/src/test/java/org/jeasy/random/context/ContextAwareRandomizationTests.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/context/ContextAwareRandomizationTests.java rename to src/test/java/org/jeasy/random/context/ContextAwareRandomizationTests.java index 1fdccb7d0..ed64b77f3 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/ContextAwareRandomizationTests.java +++ b/src/test/java/org/jeasy/random/context/ContextAwareRandomizationTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/Country.java b/src/test/java/org/jeasy/random/context/Country.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/context/Country.java rename to src/test/java/org/jeasy/random/context/Country.java index b7fb670f4..88883c8c5 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/Country.java +++ b/src/test/java/org/jeasy/random/context/Country.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/CountryRandomizer.java b/src/test/java/org/jeasy/random/context/CountryRandomizer.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/context/CountryRandomizer.java rename to src/test/java/org/jeasy/random/context/CountryRandomizer.java index 06d3d551b..b55000750 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/CountryRandomizer.java +++ b/src/test/java/org/jeasy/random/context/CountryRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/FirstNameRandomizer.java b/src/test/java/org/jeasy/random/context/FirstNameRandomizer.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/context/FirstNameRandomizer.java rename to src/test/java/org/jeasy/random/context/FirstNameRandomizer.java index 85865ca74..3735c14cb 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/FirstNameRandomizer.java +++ b/src/test/java/org/jeasy/random/context/FirstNameRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/LastNameRandomizer.java b/src/test/java/org/jeasy/random/context/LastNameRandomizer.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/context/LastNameRandomizer.java rename to src/test/java/org/jeasy/random/context/LastNameRandomizer.java index 32e55014f..fbb6d7018 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/LastNameRandomizer.java +++ b/src/test/java/org/jeasy/random/context/LastNameRandomizer.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/Person.java b/src/test/java/org/jeasy/random/context/Person.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/context/Person.java rename to src/test/java/org/jeasy/random/context/Person.java index a4be34abf..3f8dbd59c 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/Person.java +++ b/src/test/java/org/jeasy/random/context/Person.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/context/Pet.java b/src/test/java/org/jeasy/random/context/Pet.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/context/Pet.java rename to src/test/java/org/jeasy/random/context/Pet.java index 31f5ea777..b9f256bfe 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/context/Pet.java +++ b/src/test/java/org/jeasy/random/context/Pet.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/BypassSettersParameterTests.java b/src/test/java/org/jeasy/random/parameters/BypassSettersParameterTests.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/BypassSettersParameterTests.java rename to src/test/java/org/jeasy/random/parameters/BypassSettersParameterTests.java index 507f15c0e..f422db0a9 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/BypassSettersParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/BypassSettersParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/CharsetParameterTests.java b/src/test/java/org/jeasy/random/parameters/CharsetParameterTests.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/CharsetParameterTests.java rename to src/test/java/org/jeasy/random/parameters/CharsetParameterTests.java index e208e184b..bfe29e8ba 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/CharsetParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/CharsetParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/CollectionSizeRangeParameterTests.java b/src/test/java/org/jeasy/random/parameters/CollectionSizeRangeParameterTests.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/CollectionSizeRangeParameterTests.java rename to src/test/java/org/jeasy/random/parameters/CollectionSizeRangeParameterTests.java index bddd1ea31..f27d4d47f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/CollectionSizeRangeParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/CollectionSizeRangeParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/DateTimeRangeParameterTests.java b/src/test/java/org/jeasy/random/parameters/DateTimeRangeParameterTests.java similarity index 82% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/DateTimeRangeParameterTests.java rename to src/test/java/org/jeasy/random/parameters/DateTimeRangeParameterTests.java index 138b7d89d..5d5f5f0f9 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/DateTimeRangeParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/DateTimeRangeParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -50,6 +50,20 @@ void testDateRange() { assertThat(timeBean.getLocalDate()).isAfterOrEqualTo(minDate).isBeforeOrEqualTo(maxDate); } + @Test + void testDateMaxRange() { + // Given + LocalDate minDate = LocalDate.MIN; + LocalDate maxDate = LocalDate.MAX; + EasyRandomParameters parameters = new EasyRandomParameters().dateRange(minDate, maxDate); + + // When + TimeBean timeBean = new EasyRandom(parameters).nextObject(TimeBean.class); + + // Then + assertThat(timeBean.getLocalDate()).isAfterOrEqualTo(minDate).isBeforeOrEqualTo(maxDate); + } + @Test void testTimeRange() { // Given diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/ExclusionPolicyTests.java b/src/test/java/org/jeasy/random/parameters/ExclusionPolicyTests.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/ExclusionPolicyTests.java rename to src/test/java/org/jeasy/random/parameters/ExclusionPolicyTests.java index d80b9d9fc..fe49c6fed 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/ExclusionPolicyTests.java +++ b/src/test/java/org/jeasy/random/parameters/ExclusionPolicyTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/IgnoreRandomizationErrorsParameterTests.java b/src/test/java/org/jeasy/random/parameters/IgnoreRandomizationErrorsParameterTests.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/IgnoreRandomizationErrorsParameterTests.java rename to src/test/java/org/jeasy/random/parameters/IgnoreRandomizationErrorsParameterTests.java index bafcebad8..125236bc8 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/IgnoreRandomizationErrorsParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/IgnoreRandomizationErrorsParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/MaxObjectPoolSizeTests.java b/src/test/java/org/jeasy/random/parameters/MaxObjectPoolSizeTests.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/MaxObjectPoolSizeTests.java rename to src/test/java/org/jeasy/random/parameters/MaxObjectPoolSizeTests.java index 9ff6d76dc..01135f4f7 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/MaxObjectPoolSizeTests.java +++ b/src/test/java/org/jeasy/random/parameters/MaxObjectPoolSizeTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/ObjectFactoryTests.java b/src/test/java/org/jeasy/random/parameters/ObjectFactoryTests.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/ObjectFactoryTests.java rename to src/test/java/org/jeasy/random/parameters/ObjectFactoryTests.java index fc7d48ca0..02c78a71e 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/ObjectFactoryTests.java +++ b/src/test/java/org/jeasy/random/parameters/ObjectFactoryTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/OverrideDefaultInitializationParameterTests.java b/src/test/java/org/jeasy/random/parameters/OverrideDefaultInitializationParameterTests.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/OverrideDefaultInitializationParameterTests.java rename to src/test/java/org/jeasy/random/parameters/OverrideDefaultInitializationParameterTests.java index ecf4fa75f..f16f99169 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/OverrideDefaultInitializationParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/OverrideDefaultInitializationParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/RandomizationDepthParameterTests.java b/src/test/java/org/jeasy/random/parameters/RandomizationDepthParameterTests.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/RandomizationDepthParameterTests.java rename to src/test/java/org/jeasy/random/parameters/RandomizationDepthParameterTests.java index 20346e741..fbe5ca7e7 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/RandomizationDepthParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/RandomizationDepthParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/RandomizerProviderTests.java b/src/test/java/org/jeasy/random/parameters/RandomizerProviderTests.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/RandomizerProviderTests.java rename to src/test/java/org/jeasy/random/parameters/RandomizerProviderTests.java index 465c70b29..f2d3167e6 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/RandomizerProviderTests.java +++ b/src/test/java/org/jeasy/random/parameters/RandomizerProviderTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/RangeTest.java b/src/test/java/org/jeasy/random/parameters/RangeTest.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/RangeTest.java rename to src/test/java/org/jeasy/random/parameters/RangeTest.java index 504faa144..2ddcf4350 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/RangeTest.java +++ b/src/test/java/org/jeasy/random/parameters/RangeTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/ScanClasspathForConcreteTypesParameterTests.java b/src/test/java/org/jeasy/random/parameters/ScanClasspathForConcreteTypesParameterTests.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/ScanClasspathForConcreteTypesParameterTests.java rename to src/test/java/org/jeasy/random/parameters/ScanClasspathForConcreteTypesParameterTests.java index 07d8d874f..1118d1d3f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/ScanClasspathForConcreteTypesParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/ScanClasspathForConcreteTypesParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/SeedParameterTests.java b/src/test/java/org/jeasy/random/parameters/SeedParameterTests.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/SeedParameterTests.java rename to src/test/java/org/jeasy/random/parameters/SeedParameterTests.java index 5c8a00547..93bf23952 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/SeedParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/SeedParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/parameters/StringLengthRangeParameterTests.java b/src/test/java/org/jeasy/random/parameters/StringLengthRangeParameterTests.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/parameters/StringLengthRangeParameterTests.java rename to src/test/java/org/jeasy/random/parameters/StringLengthRangeParameterTests.java index 28adc498b..1c604b6a4 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/parameters/StringLengthRangeParameterTests.java +++ b/src/test/java/org/jeasy/random/parameters/StringLengthRangeParameterTests.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java similarity index 90% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java index 6aaf5a387..a10b698ed 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/AbstractRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,10 +25,14 @@ import org.jeasy.random.api.Randomizer; +import java.util.Locale; + public abstract class AbstractRandomizerTest { protected static final long SEED = 123L; + protected static final Locale LOCALE = Locale.FRANCE; + protected Randomizer randomizer; } diff --git a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/EmailRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/EmailRandomizerTest.java similarity index 97% rename from easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/EmailRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/EmailRandomizerTest.java index ae073b266..993c32e83 100644 --- a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/EmailRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/EmailRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/GenericStringRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/GenericStringRandomizerTest.java similarity index 97% rename from easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/GenericStringRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/GenericStringRandomizerTest.java index 8f822808b..ba7079a39 100644 --- a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/GenericStringRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/GenericStringRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/PasswordRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/PasswordRandomizerTest.java similarity index 97% rename from easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/PasswordRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/PasswordRandomizerTest.java index 59e187b98..cc7d3edf4 100644 --- a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/PasswordRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/PasswordRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/RandomizersTest.java b/src/test/java/org/jeasy/random/randomizers/RandomizersTest.java similarity index 65% rename from easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/RandomizersTest.java rename to src/test/java/org/jeasy/random/randomizers/RandomizersTest.java index ea328d847..453db2c22 100644 --- a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/RandomizersTest.java +++ b/src/test/java/org/jeasy/random/randomizers/RandomizersTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,6 @@ import static org.assertj.core.api.BDDAssertions.then; -import java.text.DecimalFormatSymbols; - import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -72,28 +70,28 @@ void generatedNumberShouldNotBeNull(Randomizer randomizer) { static Object[][] generateSeededRandomizersAndTheirExpectedValues() { return new Object[][] { - { new CityRandomizer(SEED), "Breannaberg" }, + { new CityRandomizer(SEED), "Breannashire" }, { new CompanyRandomizer(SEED), "Hegmann, Hansen and Mills" }, - { new CountryRandomizer(SEED), "Peru" }, - { new CreditCardNumberRandomizer(SEED), "1211-1221-1234-2201" }, + { new CountryRandomizer(SEED), "Christmas Island" }, + { new CreditCardNumberRandomizer(SEED), "5038-0547-6719-9874" }, { new EmailRandomizer(SEED), "jacob.hansen@hotmail.com" }, { new FirstNameRandomizer(SEED), "Jacob" }, { new FullNameRandomizer(SEED), "Breanna Mills" }, { new Ipv4AddressRandomizer(SEED), "16.188.76.229" }, - { new Ipv6AddressRandomizer(SEED), "b3f4:4994:c9e8:b21a:c493:e923:f711:1115" }, - { new IsbnRandomizer(SEED), "9781797845005" }, + { new Ipv6AddressRandomizer(SEED), "d119:54cc:1cbd:a03d:6170:26a2:57ab:af62" }, + { new IsbnRandomizer(SEED), "9790893392719" }, { new LastNameRandomizer(SEED), "Durgan" }, - { new LatitudeRandomizer(SEED), "40" + new DecimalFormatSymbols().getDecimalSeparator() + "171357" }, - { new LongitudeRandomizer(SEED), "80" + new DecimalFormatSymbols().getDecimalSeparator() + "342713" }, + { new LatitudeRandomizer(SEED), "40.17135654" }, + { new LongitudeRandomizer(SEED), "80.34271308" }, { new MacAddressRandomizer(SEED), "b3:f4:49:94:c9:e8" }, - { new ParagraphRandomizer(SEED), "Totam assumenda eius autem similique. Aut voluptatem enim praesentium. Suscipit cupiditate doloribus debitis dolor. Cumque sapiente occaecati. Quos maiores quae." }, - { new PhoneNumberRandomizer(SEED), "1-069-574-7539" }, - { new RegularExpressionRandomizer("\\d+[A-Z]{5}", SEED), "8UYSMT" }, - { new SentenceRandomizer(SEED), "Dolor totam assumenda eius autem." }, + { new ParagraphRandomizer(SEED), "Ducimus delectus dolorum eligendi aspernatur. Voluptatibus itaque neque sunt. Excepturi itaque est reprehenderit occaecati. Maxime impedit explicabo. Aspernatur quaerat aliquam." }, + { new PhoneNumberRandomizer(SEED), "(386) 474-7539" }, + { new RegularExpressionRandomizer("\\d+[A-Z]{5}", SEED), "06957475396257905462760838214120325345682304630806404312817939078870089456356705559PFQGT" }, + { new SentenceRandomizer(SEED), "Mollitia ducimus delectus dolorum eligendi." }, { new StateRandomizer(SEED), "North Carolina" }, - { new StreetRandomizer(SEED), "Hegmann Locks" }, - { new WordRandomizer(SEED), "repellat" }, - { new ZipCodeRandomizer(SEED), "06957-4753" } + { new StreetRandomizer(SEED), "Hegmann Park" }, + { new WordRandomizer(SEED), "quaerat" }, + { new ZipCodeRandomizer(SEED), "28740" } }; } @@ -108,27 +106,27 @@ void shouldGenerateTheSameValueForTheSameSeed(Randomizer randomizer, Object e static Object[][] generateSeededRandomizersWithLocaleAndTheirExpectedValues() { return new Object[][] { - { new CityRandomizer(SEED, LOCALE), "Versailles" }, + { new CityRandomizer(SEED, LOCALE), "Cholet" }, { new CompanyRandomizer(SEED, LOCALE), "Masson et Lambert" }, - { new CountryRandomizer(SEED, LOCALE), "Peru" }, - { new CreditCardNumberRandomizer(SEED, LOCALE), "1211-1221-1234-2201" }, + { new CountryRandomizer(SEED, LOCALE), "Christmas Island" }, + { new CreditCardNumberRandomizer(SEED, LOCALE), "5038-0547-6719-9874" }, { new EmailRandomizer(SEED, LOCALE), "alice.masson@hotmail.fr" }, { new FirstNameRandomizer(SEED, LOCALE), "Alice" }, { new FullNameRandomizer(SEED, LOCALE), "Masson Emilie" }, { new Ipv4AddressRandomizer(SEED, LOCALE), "16.188.76.229" }, - { new Ipv6AddressRandomizer(SEED, LOCALE), "b3f4:4994:c9e8:b21a:c493:e923:f711:1115" }, - { new IsbnRandomizer(SEED, LOCALE), "9781797845005" }, + { new Ipv6AddressRandomizer(SEED, LOCALE), "d119:54cc:1cbd:a03d:6170:26a2:57ab:af62" }, + { new IsbnRandomizer(SEED, LOCALE), "9790893392719" }, { new LastNameRandomizer(SEED, LOCALE), "Faure" }, - { new LatitudeRandomizer(SEED, LOCALE), "40" + new DecimalFormatSymbols().getDecimalSeparator() + "171357" }, // should really be "40.171357", seems like a bug in java-faker - { new LongitudeRandomizer(SEED, LOCALE), "80" + new DecimalFormatSymbols().getDecimalSeparator() + "342713" }, // should really be "80.342713", seems like a bug in java-faker + { new LatitudeRandomizer(SEED, LOCALE), "40,17135654" }, + { new LongitudeRandomizer(SEED, LOCALE), "80,34271308" }, { new MacAddressRandomizer(SEED, LOCALE), "b3:f4:49:94:c9:e8" }, - { new ParagraphRandomizer(SEED, LOCALE), "Totam assumenda eius autem similique. Aut voluptatem enim praesentium. Suscipit cupiditate doloribus debitis dolor. Cumque sapiente occaecati. Quos maiores quae." }, - { new PhoneNumberRandomizer(SEED, LOCALE), "03 06 95 74 75" }, - { new SentenceRandomizer(SEED, LOCALE), "Dolor totam assumenda eius autem." }, + { new ParagraphRandomizer(SEED, LOCALE), "Ducimus delectus dolorum eligendi aspernatur. Voluptatibus itaque neque sunt. Excepturi itaque est reprehenderit occaecati. Maxime impedit explicabo. Aspernatur quaerat aliquam." }, + { new PhoneNumberRandomizer(SEED, LOCALE), "03 95 74 75 39" }, + { new SentenceRandomizer(SEED, LOCALE), "Mollitia ducimus delectus dolorum eligendi." }, { new StateRandomizer(SEED, LOCALE), "Lorraine" }, - { new StreetRandomizer(SEED, LOCALE), "Rue de Presbourg" }, - { new WordRandomizer(SEED, LOCALE), "repellat" }, - { new ZipCodeRandomizer(SEED, LOCALE), "06957" } + { new StreetRandomizer(SEED, LOCALE), "Passage des Francs-Bourgeois" }, + { new WordRandomizer(SEED, LOCALE), "quaerat" }, + { new ZipCodeRandomizer(SEED, LOCALE), "28740" } }; } diff --git a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/RegularExpressionRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/RegularExpressionRandomizerTest.java similarity index 97% rename from easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/RegularExpressionRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/RegularExpressionRandomizerTest.java index c8c1e1a15..f1cf89cbf 100644 --- a/easy-random-randomizers/src/test/java/org/jeasy/random/randomizers/RegularExpressionRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/RegularExpressionRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/CollectionRandomizersTest.java b/src/test/java/org/jeasy/random/randomizers/collection/CollectionRandomizersTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/CollectionRandomizersTest.java rename to src/test/java/org/jeasy/random/randomizers/collection/CollectionRandomizersTest.java index 295a9af43..be1dca3fa 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/CollectionRandomizersTest.java +++ b/src/test/java/org/jeasy/random/randomizers/collection/CollectionRandomizersTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/EnumSetRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/collection/EnumSetRandomizerTest.java similarity index 79% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/EnumSetRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/collection/EnumSetRandomizerTest.java index d98e297fd..b49c64eaa 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/EnumSetRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/collection/EnumSetRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -47,4 +47,19 @@ void testEnumSetGeneration() { assertThat(randomEnumSet).containsAnyElementsOf(asList(Month.values())); } -} \ No newline at end of file + @Test + void testEnumSetGenerationWithZeroRequestedElements() { + // given + EnumRandomizer delegate = new EnumRandomizer<>(Month.class); + EnumSetRandomizer randomizer = new EnumSetRandomizer<>(delegate, 0); + + // when + EnumSet randomEnumSet = randomizer.getRandomValue(); + + // then + assertThat(randomEnumSet) + .hasSize(1) + .containsAnyElementsOf(asList(Month.values())); + } + +} diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/MapRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/collection/MapRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/MapRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/collection/MapRandomizerTest.java index f342cda90..10870d28b 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/collection/MapRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/collection/MapRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/BooleanRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/BooleanRandomizerTest.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/BooleanRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/BooleanRandomizerTest.java index b13266dda..d2c27270e 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/BooleanRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/BooleanRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/ConstantRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/ConstantRandomizerTest.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/ConstantRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/ConstantRandomizerTest.java index d1bc8674f..9af1c22a1 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/ConstantRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/ConstantRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/EnumRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/EnumRandomizerTest.java similarity index 84% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/EnumRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/EnumRandomizerTest.java index 217fabba1..9eab51201 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/EnumRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/EnumRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -43,6 +43,13 @@ void shouldAlwaysGenerateTheSameValueForTheSameSeed() { assertThat(new EnumRandomizer(Gender.class, SEED).getRandomValue()).isEqualTo(FEMALE); } + @Test + void shouldAlwaysGenerateTheSameValueForTheSameSeedWithExcludedValues() { + assertThat( + new EnumRandomizer<>(TriState.class, SEED, TriState.Maybe).getRandomValue()).isEqualTo( + TriState.False); + } + public enum Gender { MALE, FEMALE } @@ -67,4 +74,11 @@ public void should_return_null_for_empty_enum() { Empty randomElement = new EnumRandomizer<>(Empty.class).getRandomValue(); assertThat(randomElement).isNull(); } + + // always keep three options here, as we want to exclude one and still select the same one + // deterministically + @SuppressWarnings("unused") + private enum TriState { + True, False, Maybe + } } diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/LocaleRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/LocaleRandomizerTest.java similarity index 62% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/LocaleRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/LocaleRandomizerTest.java index 0b374b4bf..d9b9c67cf 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/LocaleRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/LocaleRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.math.BigDecimal; import java.util.Locale; import org.junit.jupiter.api.Test; @@ -41,17 +40,12 @@ void shouldGenerateRandomLocale() { @Test void shouldGenerateTheSameValueForTheSameSeed() { - BigDecimal javaVersion = new BigDecimal(System.getProperty("java.specification.version")); - if (javaVersion.compareTo(new BigDecimal("14")) >= 0) { - assertThat(new LocaleRandomizer(SEED).getRandomValue()).isEqualTo(new Locale("rn", "BI")); - } else if (javaVersion.compareTo(new BigDecimal("13")) >= 0) { - assertThat(new LocaleRandomizer(SEED).getRandomValue()).isEqualTo(new Locale("zh", "CN")); - } else if (javaVersion.compareTo(new BigDecimal("11")) >= 0) { - assertThat(new LocaleRandomizer(SEED).getRandomValue()).isEqualTo(new Locale("en", "CK")); - } else if (javaVersion.compareTo(new BigDecimal("9")) >= 0) { - assertThat(new LocaleRandomizer(SEED).getRandomValue()).isEqualTo(new Locale("sw", "ke")); - } else { - assertThat(new LocaleRandomizer(SEED).getRandomValue()).isEqualTo(new Locale("nl", "be")); - } + Locale first = new LocaleRandomizer(SEED).getRandomValue(); + Locale second = new LocaleRandomizer(SEED).getRandomValue(); + + assertThat(first).isEqualTo(second); + Locale[] availableLocales = Locale.getAvailableLocales(); + assertThat(first).isIn(availableLocales); + assertThat(second).isIn(availableLocales); } } diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/NullRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/NullRandomizerTest.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/NullRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/NullRandomizerTest.java index b4759adea..c0fe6c32d 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/NullRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/NullRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/OptionalRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/OptionalRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/OptionalRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/OptionalRandomizerTest.java index 2f79ccd14..1fd638caf 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/OptionalRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/OptionalRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/SkipRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/SkipRandomizerTest.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/SkipRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/SkipRandomizerTest.java index 9d1fe113b..67d011a9c 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/SkipRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/SkipRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/UUIDRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/misc/UUIDRandomizerTest.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/UUIDRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/misc/UUIDRandomizerTest.java index 9484289be..b24136d47 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/misc/UUIDRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/misc/UUIDRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/net/NetRandomizersTest.java b/src/test/java/org/jeasy/random/randomizers/net/NetRandomizersTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/net/NetRandomizersTest.java rename to src/test/java/org/jeasy/random/randomizers/net/NetRandomizersTest.java index d1120d957..ca0a21468 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/net/NetRandomizersTest.java +++ b/src/test/java/org/jeasy/random/randomizers/net/NetRandomizersTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizerTest.java index 8e22a2415..b00ab0b1d 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/number/AtomicIntegerRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/AtomicLongRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/number/AtomicLongRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/number/AtomicLongRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/number/AtomicLongRandomizerTest.java index ffc89d850..73f5ac5b3 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/AtomicLongRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/number/AtomicLongRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/BigDecimalRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/number/BigDecimalRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/number/BigDecimalRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/number/BigDecimalRandomizerTest.java index 09ed9d3e5..ed6eabca5 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/BigDecimalRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/number/BigDecimalRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/NumberRandomizersTest.java b/src/test/java/org/jeasy/random/randomizers/number/NumberRandomizersTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/number/NumberRandomizersTest.java rename to src/test/java/org/jeasy/random/randomizers/number/NumberRandomizersTest.java index 40915ff4a..faf69c9ee 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/number/NumberRandomizersTest.java +++ b/src/test/java/org/jeasy/random/randomizers/number/NumberRandomizersTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizerTest.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizerTest.java index 426b70773..850b2a973 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/AbstractRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizerTest.java similarity index 83% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizerTest.java index b776cb638..ac32a089f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,6 +30,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; +import org.jeasy.random.util.ReflectionUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -92,6 +93,23 @@ void generatedValueShouldHaveProvidedPositiveScale() { then(bigDecimal.scale()).isEqualTo(scale); } + @Test + void generatedValueShouldHaveProvidedPositiveScaleAndRoundingMode() throws NoSuchFieldException, IllegalAccessException { + // given + Integer scale = 2; + RoundingMode roundingMode = RoundingMode.DOWN; + BigDecimalRangeRandomizer bigDecimalRangeRandomizer = new BigDecimalRangeRandomizer(min, max, scale, roundingMode); + + // when + BigDecimal bigDecimal = bigDecimalRangeRandomizer.getRandomValue(); + + then(bigDecimal.scale()).isEqualTo(scale); + + var field = bigDecimalRangeRandomizer.getClass().getDeclaredField("roundingMode"); + var actualRoundingMode = ReflectionUtils.getFieldValue(bigDecimalRangeRandomizer, field); + then(actualRoundingMode).isEqualTo(RoundingMode.DOWN); + } + @Test void generatedValueShouldHaveProvidedNegativeScale() { // given diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizerTest.java index 4a87bc438..bf2c3d51c 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/BigIntegerRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ByteRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/ByteRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ByteRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/ByteRangeRandomizerTest.java index a12fa021b..69e0fd850 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ByteRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/ByteRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/DateRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/DateRangeRandomizerTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/DateRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/DateRangeRandomizerTest.java index 4df502b37..3f429a2bc 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/DateRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/DateRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizerTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizerTest.java index ba5daa25d..90a12fe58 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/DoubleRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/FloatRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/FloatRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/FloatRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/FloatRangeRandomizerTest.java index 26624354e..16895d72d 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/FloatRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/FloatRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/InstantRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/InstantRangeRandomizerTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/InstantRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/InstantRangeRandomizerTest.java index ca02e2824..2325ffa1f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/InstantRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/InstantRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizerTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizerTest.java index 50a73e2f5..f5ff4bb26 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/IntegerRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizerTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizerTest.java index 68f5b75e5..b95b3a1e3 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/LocalDateRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizerTest.java index cd53cc3c4..cfc5ae539 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/LocalDateTimeRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -57,7 +57,7 @@ void generatedLocalDateTimeShouldBeAlwaysTheSameForTheSameSeed() { // Given randomizer = new LocalDateTimeRangeRandomizer(minDateTime, maxDateTime, SEED); - LocalDateTime expected = LocalDateTime.parse("+446348406-04-09T16:32:16.990898895"); + LocalDateTime expected = LocalDateTime.parse("+446348406-04-09T16:32:16.647624789"); // When LocalDateTime randomValue = randomizer.getRandomValue(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizerTest.java similarity index 82% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizerTest.java index 8eff10bf6..d89059f64 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/LocalTimeRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.time.LocalTime; +import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -52,11 +53,28 @@ void generatedLocalTimeShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minTime, maxTime); } + @Test + void generatedLocalTimeShouldReachSpecifiedUpperBound() { + // Given + minTime = LocalTime.MAX.minusNanos(1); + maxTime = LocalTime.MAX; + randomizer = new LocalTimeRangeRandomizer(minTime, maxTime); + + // When + LocalTime maxObserved = Stream.generate(() -> randomizer.getRandomValue()) + .limit(10_000) + .max(LocalTime::compareTo) + .orElseThrow(); + + // Then + assertThat(maxObserved).isEqualTo(maxTime); + } + @Test void generatedLocalTimeShouldBeAlwaysTheSameForTheSameSeed() { // Given randomizer = new LocalTimeRangeRandomizer(minTime, maxTime, SEED); - LocalTime expected = LocalTime.of(14, 14, 58, 723174202); + LocalTime expected = LocalTime.of(5, 56, 50, 553004782); // When LocalTime randomValue = randomizer.getRandomValue(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LongRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/LongRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LongRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/LongRangeRandomizerTest.java index 57ae62701..85cee5f92 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/LongRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/LongRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizerTest.java index 375b3d021..060b6615f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/OffsetDateTimeRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -57,7 +57,7 @@ void generatedOffsetDateTimeShouldBeWithinSpecifiedRange() { void generatedOffsetDateTimeShouldBeAlwaysTheSameForTheSameSeed() { // Given randomizer = new OffsetDateTimeRangeRandomizer(minOffsetDateTime, maxOffsetDateTime, SEED); - OffsetDateTime expected = OffsetDateTime.parse("2046-10-12T17:24:27Z"); + OffsetDateTime expected = OffsetDateTime.parse("2046-10-12T17:24:28Z"); // When OffsetDateTime randomValue = randomizer.getRandomValue(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizerTest.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizerTest.java index 098f0d59e..71dce2ec4 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/OffsetTimeRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -57,7 +57,7 @@ void generatedOffsetTimeShouldBeWithinSpecifiedRange() { void generatedOffsetTimeShouldBeAlwaysTheSameForTheSameSeed() { // Given randomizer = new OffsetTimeRangeRandomizer(minTime, maxTime, SEED); - OffsetTime expected = OffsetTime.of(17, 21, 21, 0, ZoneOffset.UTC); + OffsetTime expected = OffsetTime.of(17, 21, 22, 0, ZoneOffset.UTC); // When OffsetTime randomValue = randomizer.getRandomValue(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ShortRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/ShortRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ShortRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/ShortRangeRandomizerTest.java index 1c99e4bb7..eae385997 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ShortRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/ShortRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizerTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizerTest.java index 11a8b8aa4..f513e1199 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/SqlDateRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizerTest.java similarity index 94% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizerTest.java index 594f4687a..7af109f3b 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/YearMonthRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -79,7 +79,7 @@ void whenSpecifiedMinYearMonthIsNull_thenShouldUseDefaultMinValue() { YearMonth randomValue = randomizer.getRandomValue(); // Then - assertThat(randomValue).isLessThanOrEqualTo(maxYearMonth); + assertThat(randomValue).isBeforeOrEqualTo(maxYearMonth); } @Test @@ -91,6 +91,6 @@ void whenSpecifiedMaxYearMonthIsNull_thenShouldUseDefaultMaxValue() { YearMonth randomValue = randomizer.getRandomValue(); // Then - assertThat(randomValue).isGreaterThanOrEqualTo(minYearMonth); + assertThat(randomValue).isAfterOrEqualTo(minYearMonth); } } diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/YearRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/YearRangeRandomizerTest.java similarity index 98% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/YearRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/YearRangeRandomizerTest.java index 472eda718..15d6e85b5 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/YearRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/YearRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizerTest.java index 119a93f7b..90693f32a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/range/ZonedDateTimeRangeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -57,7 +57,7 @@ void generatedZonedDateTimeShouldBeWithinSpecifiedRange() { void generatedZonedDateTimeShouldBeAlwaysTheSameForTheSameSeed() { // Given randomizer = new ZonedDateTimeRangeRandomizer(minZonedDateTime, maxZonedDateTime, SEED); - ZonedDateTime expected = ZonedDateTime.parse("2046-10-12T17:24:27Z"); + ZonedDateTime expected = ZonedDateTime.parse("2046-10-12T17:24:28Z[UTC]"); // When ZonedDateTime randomValue = randomizer.getRandomValue(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/text/CharacterRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/text/CharacterRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/text/CharacterRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/text/CharacterRandomizerTest.java index 3bf4a115c..72ba53eae 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/text/CharacterRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/text/CharacterRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizerTest.java index 425b3e91d..42c871d46 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/text/StringDelegatingRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/text/StringRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/text/StringRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/text/StringRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/text/StringRandomizerTest.java index 0e9a89ac5..a42ed5f96 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/text/StringRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/text/StringRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeRandomizersTest.java b/src/test/java/org/jeasy/random/randomizers/time/TimeRandomizersTest.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeRandomizersTest.java rename to src/test/java/org/jeasy/random/randomizers/time/TimeRandomizersTest.java index eb5ff1334..71982b5b7 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeRandomizersTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/TimeRandomizersTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -103,7 +103,7 @@ static Object[][] generateSeededRandomizersAndTheirExpectedValues() { { new DurationRandomizer(SEED, ChronoUnit.MILLIS), Duration.of(72L, ChronoUnit.MILLIS) }, { new LocalDateRandomizer(SEED), LocalDate.of(2024, Month.MARCH, 20) }, { new MonthDayRandomizer(SEED), MonthDay.of(Month.MARCH, 20) }, - { new LocalTimeRandomizer(SEED), LocalTime.of(16, 42, 58, 723174202) }, + { new LocalTimeRandomizer(SEED), LocalTime.of(17, 43, 59, 723174202) }, { new PeriodRandomizer(SEED), Period.of(2024, 3, 20) }, { new YearRandomizer(SEED), Year.of(2024) }, { new YearMonthRandomizer(SEED), YearMonth.of(2024, Month.MARCH) }, @@ -112,9 +112,9 @@ static Object[][] generateSeededRandomizersAndTheirExpectedValues() { { new DateRandomizer(SEED), new Date(1718736844570L) }, { new GregorianCalendarRandomizer(SEED), expectedGregorianCalendar }, { new InstantRandomizer(SEED), Instant.ofEpochSecond(1718736844L, 570000000) }, - { new LocalDateTimeRandomizer(SEED), LocalDateTime.of(2024, Month.MARCH, 20, 16, 42, 58, 723174202) }, - { new OffsetDateTimeRandomizer(SEED), OffsetDateTime.of(of(2024, Month.MARCH, 20, 16, 42, 58, 723174202), ofTotalSeconds(28923)) }, - { new OffsetTimeRandomizer(SEED), OffsetTime.of(LocalTime.of(16, 42, 58, 723174202), ofTotalSeconds(28923)) }, + { new LocalDateTimeRandomizer(SEED), LocalDateTime.of(2024, Month.MARCH, 20, 17, 43, 59, 723174202) }, + { new OffsetDateTimeRandomizer(SEED), OffsetDateTime.of(of(2024, Month.MARCH, 20, 17, 43, 59, 723174202), ofTotalSeconds(28923)) }, + { new OffsetTimeRandomizer(SEED), OffsetTime.of(LocalTime.of(17, 43, 59, 723174202), ofTotalSeconds(28923)) }, { new SqlDateRandomizer(SEED), new java.sql.Date(1718736844570L) }, { new SqlTimeRandomizer(SEED), new Time(1718736844570L) }, { new SqlTimestampRandomizer(SEED), new Timestamp(1718736844570L) } diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeSupportTest.java b/src/test/java/org/jeasy/random/randomizers/time/TimeSupportTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeSupportTest.java rename to src/test/java/org/jeasy/random/randomizers/time/TimeSupportTest.java index 61736832d..c620726e9 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeSupportTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/TimeSupportTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeZoneRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/time/TimeZoneRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeZoneRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/time/TimeZoneRandomizerTest.java index 934a218d0..3cb463320 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/TimeZoneRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/TimeZoneRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/ZoneIdRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/time/ZoneIdRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/ZoneIdRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/time/ZoneIdRandomizerTest.java index 0dbcfc807..0eb09272d 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/ZoneIdRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/ZoneIdRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizerTest.java index 9a8674cdb..d1258823a 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/ZonedDateTimeRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/DayRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/time/internal/DayRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/DayRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/time/internal/DayRandomizerTest.java index aed863a18..c3cc908d4 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/DayRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/internal/DayRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/HourRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/time/internal/HourRandomizerTest.java similarity index 84% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/HourRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/time/internal/HourRandomizerTest.java index 5365b2f5f..19589ef7e 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/HourRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/internal/HourRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,6 +27,8 @@ import static org.jeasy.random.randomizers.time.HourRandomizer.MIN_HOUR; import static org.assertj.core.api.Assertions.assertThat; +import java.util.stream.IntStream; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -50,11 +52,21 @@ void generatedValueShouldBeWithinRange() { assertThat(randomizer.getRandomValue()).isBetween(MIN_HOUR, MAX_HOUR); } + @Test + void generatedValuesShouldReachUpperBound() { + int maxHour = IntStream.range(0, 100_000) + .map(i -> randomizer.getRandomValue()) + .max() + .orElseThrow(); + + assertThat(maxHour).isEqualTo(MAX_HOUR); + } + @Test void shouldGenerateTheSameValueForTheSameSeed() { // Given randomizer = new HourRandomizer(SEED); - Integer expected = 16; + Integer expected = 17; // When Integer actual = randomizer.getRandomValue(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/MinuteRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/time/internal/MinuteRandomizerTest.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/MinuteRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/time/internal/MinuteRandomizerTest.java index 35c98a178..8d1464b76 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/MinuteRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/internal/MinuteRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -54,7 +54,7 @@ void generatedValueShouldBeWithinRange() { void shouldGenerateTheSameValueForTheSameSeed() { // Given randomizer = new MinuteRandomizer(SEED); - Integer expected = 42; + Integer expected = 43; // When Integer actual = randomizer.getRandomValue(); diff --git a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/NanoSecondRandomizerTest.java b/src/test/java/org/jeasy/random/randomizers/time/internal/NanoSecondRandomizerTest.java similarity index 97% rename from easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/NanoSecondRandomizerTest.java rename to src/test/java/org/jeasy/random/randomizers/time/internal/NanoSecondRandomizerTest.java index de3713623..411b7631e 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/randomizers/time/internal/NanoSecondRandomizerTest.java +++ b/src/test/java/org/jeasy/random/randomizers/time/internal/NanoSecondRandomizerTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/test/java/org/jeasy/random/records/AccessBadge.java b/src/test/java/org/jeasy/random/records/AccessBadge.java new file mode 100644 index 000000000..8a0f9925b --- /dev/null +++ b/src/test/java/org/jeasy/random/records/AccessBadge.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record AccessBadge(String badgeId, String clearanceLevel, String issuer) { +} diff --git a/src/test/java/org/jeasy/random/records/CargoBay.java b/src/test/java/org/jeasy/random/records/CargoBay.java new file mode 100644 index 000000000..b9d65573e --- /dev/null +++ b/src/test/java/org/jeasy/random/records/CargoBay.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record CargoBay(String cargoCode, SupplyCrate supplyCrate, CargoInspector cargoInspector) { +} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveAnnotationHandler.java b/src/test/java/org/jeasy/random/records/CargoInspector.java similarity index 59% rename from easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveAnnotationHandler.java rename to src/test/java/org/jeasy/random/records/CargoInspector.java index 72bf1441a..c1bffcff3 100644 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/PositiveAnnotationHandler.java +++ b/src/test/java/org/jeasy/random/records/CargoInspector.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,21 +21,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.jeasy.random.validation; +package org.jeasy.random.records; -import org.jeasy.random.api.Randomizer; +public class CargoInspector { -import java.lang.reflect.Field; -import java.math.BigDecimal; + private String inspectorName; + private String shiftCode; + private WeatherWindow weatherWindow; -class PositiveAnnotationHandler extends AbstractNumberBaseAnnotationHandler { + public CargoInspector() { + } + + public String getInspectorName() { + return inspectorName; + } + + public void setInspectorName(String inspectorName) { + this.inspectorName = inspectorName; + } + + public String getShiftCode() { + return shiftCode; + } + + public void setShiftCode(String shiftCode) { + this.shiftCode = shiftCode; + } - PositiveAnnotationHandler(final long seed) { - super(seed); + public WeatherWindow getWeatherWindow() { + return weatherWindow; } - @Override - public Randomizer getRandomizer(Field field) { - return getRandomizer(field.getType(), BigDecimal.ONE, null); + public void setWeatherWindow(WeatherWindow weatherWindow) { + this.weatherWindow = weatherWindow; } } diff --git a/src/test/java/org/jeasy/random/records/CityRegistryEntry.java b/src/test/java/org/jeasy/random/records/CityRegistryEntry.java new file mode 100644 index 000000000..e8c0a4c27 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/CityRegistryEntry.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record CityRegistryEntry(String registryId, ResidentProfile residentProfile) { +} diff --git a/src/test/java/org/jeasy/random/records/CommandConsole.java b/src/test/java/org/jeasy/random/records/CommandConsole.java new file mode 100644 index 000000000..c70602824 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/CommandConsole.java @@ -0,0 +1,58 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public class CommandConsole { + + private String consoleId; + private WeatherWindow weatherWindow; + private AccessBadge accessBadge; + + public CommandConsole() { + } + + public String getConsoleId() { + return consoleId; + } + + public void setConsoleId(String consoleId) { + this.consoleId = consoleId; + } + + public WeatherWindow getWeatherWindow() { + return weatherWindow; + } + + public void setWeatherWindow(WeatherWindow weatherWindow) { + this.weatherWindow = weatherWindow; + } + + public AccessBadge getAccessBadge() { + return accessBadge; + } + + public void setAccessBadge(AccessBadge accessBadge) { + this.accessBadge = accessBadge; + } +} diff --git a/src/test/java/org/jeasy/random/records/Dog.java b/src/test/java/org/jeasy/random/records/Dog.java new file mode 100644 index 000000000..0bdeec455 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/Dog.java @@ -0,0 +1,28 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public interface Dog { + void bark(); +} \ No newline at end of file diff --git a/src/test/java/org/jeasy/random/records/DogOwner.java b/src/test/java/org/jeasy/random/records/DogOwner.java new file mode 100644 index 000000000..e67b799f7 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/DogOwner.java @@ -0,0 +1,26 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record DogOwner(String ownerName, Dog dog) {} \ No newline at end of file diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/package-info.java b/src/test/java/org/jeasy/random/records/ExpeditionManifest.java similarity index 82% rename from easy-random-bean-validation/src/main/java/org/jeasy/random/validation/package-info.java rename to src/test/java/org/jeasy/random/records/ExpeditionManifest.java index aaf15e0d3..a7f922e6b 100644 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/package-info.java +++ b/src/test/java/org/jeasy/random/records/ExpeditionManifest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,9 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -/** - * This package contains Bean Validation support registry. - * - * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) - */ -package org.jeasy.random.validation; +package org.jeasy.random.records; + +public record ExpeditionManifest(ManifestReference manifestReference, ExpeditionVehicle expeditionVehicle, MissionCommander missionCommander) { +} diff --git a/src/test/java/org/jeasy/random/records/ExpeditionVehicle.java b/src/test/java/org/jeasy/random/records/ExpeditionVehicle.java new file mode 100644 index 000000000..f1b20443f --- /dev/null +++ b/src/test/java/org/jeasy/random/records/ExpeditionVehicle.java @@ -0,0 +1,33 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public interface ExpeditionVehicle { + + String vehicleName(); + + LaunchBay launchBay(); + + CargoBay cargoBay(); +} diff --git a/src/test/java/org/jeasy/random/records/IdentityCard.java b/src/test/java/org/jeasy/random/records/IdentityCard.java new file mode 100644 index 000000000..ba03e65a5 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/IdentityCard.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record IdentityCard(String documentNumber, Person person) { +} diff --git a/src/test/java/org/jeasy/random/records/LaunchBay.java b/src/test/java/org/jeasy/random/records/LaunchBay.java new file mode 100644 index 000000000..c39f7f507 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/LaunchBay.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record LaunchBay(String bayCode, WeatherWindow weatherWindow, AccessBadge accessBadge) { +} diff --git a/src/test/java/org/jeasy/random/records/ManifestReference.java b/src/test/java/org/jeasy/random/records/ManifestReference.java new file mode 100644 index 000000000..a443c52be --- /dev/null +++ b/src/test/java/org/jeasy/random/records/ManifestReference.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record ManifestReference(String manifestCode, String departureZone, String priorityLabel) { +} diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/EmailAnnotationHandler.java b/src/test/java/org/jeasy/random/records/MissionCommander.java similarity index 60% rename from easy-random-bean-validation/src/main/java/org/jeasy/random/validation/EmailAnnotationHandler.java rename to src/test/java/org/jeasy/random/records/MissionCommander.java index 5b1b3a101..48317ec8d 100644 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/EmailAnnotationHandler.java +++ b/src/test/java/org/jeasy/random/records/MissionCommander.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,24 +21,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.jeasy.random.validation; +package org.jeasy.random.records; -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.EmailRandomizer; +public class MissionCommander { -import java.lang.reflect.Field; -import java.util.Random; + private String commanderName; + private String rank; + private CommandConsole commandConsole; -class EmailAnnotationHandler implements BeanValidationAnnotationHandler { + public MissionCommander() { + } + + public String getCommanderName() { + return commanderName; + } + + public void setCommanderName(String commanderName) { + this.commanderName = commanderName; + } + + public String getRank() { + return rank; + } - private final Random random; + public void setRank(String rank) { + this.rank = rank; + } - EmailAnnotationHandler(final long seed) { - random = new Random(seed); + public CommandConsole getCommandConsole() { + return commandConsole; } - @Override - public Randomizer getRandomizer(Field field) { - return new EmailRandomizer(random.nextLong()); + public void setCommandConsole(CommandConsole commandConsole) { + this.commandConsole = commandConsole; } } diff --git a/src/test/java/org/jeasy/random/records/NationalIdentityCard.java b/src/test/java/org/jeasy/random/records/NationalIdentityCard.java new file mode 100644 index 000000000..2b8285774 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/NationalIdentityCard.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record NationalIdentityCard(String referenceNumber, Person person) implements ResidentDocument { +} diff --git a/src/test/java/org/jeasy/random/records/Person.java b/src/test/java/org/jeasy/random/records/Person.java new file mode 100644 index 000000000..b9f26eb53 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/Person.java @@ -0,0 +1,26 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record Person(Long id, String name){} \ No newline at end of file diff --git a/src/test/java/org/jeasy/random/records/ResearchAirship.java b/src/test/java/org/jeasy/random/records/ResearchAirship.java new file mode 100644 index 000000000..99922083b --- /dev/null +++ b/src/test/java/org/jeasy/random/records/ResearchAirship.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record ResearchAirship(String vehicleName, LaunchBay launchBay, CargoBay cargoBay) implements ExpeditionVehicle { +} diff --git a/src/test/java/org/jeasy/random/records/ResidentArchiveEntry.java b/src/test/java/org/jeasy/random/records/ResidentArchiveEntry.java new file mode 100644 index 000000000..73559d7f4 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/ResidentArchiveEntry.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record ResidentArchiveEntry(String archiveId, ResidentDocument residentDocument) { +} diff --git a/src/test/java/org/jeasy/random/records/ResidentDocument.java b/src/test/java/org/jeasy/random/records/ResidentDocument.java new file mode 100644 index 000000000..b6f3cad5f --- /dev/null +++ b/src/test/java/org/jeasy/random/records/ResidentDocument.java @@ -0,0 +1,31 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public interface ResidentDocument { + + String referenceNumber(); + + Person person(); +} diff --git a/src/test/java/org/jeasy/random/records/ResidentProfile.java b/src/test/java/org/jeasy/random/records/ResidentProfile.java new file mode 100644 index 000000000..529172576 --- /dev/null +++ b/src/test/java/org/jeasy/random/records/ResidentProfile.java @@ -0,0 +1,27 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record ResidentProfile(String city, IdentityCard identityCard) { +} diff --git a/src/test/java/org/jeasy/random/records/Rottweiler.java b/src/test/java/org/jeasy/random/records/Rottweiler.java new file mode 100644 index 000000000..787e7c8cf --- /dev/null +++ b/src/test/java/org/jeasy/random/records/Rottweiler.java @@ -0,0 +1,32 @@ +/* + * The MIT License + * + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.jeasy.random.records; + +public record Rottweiler(String name) implements Dog { + + @Override + public void bark() { + System.out.println(name + "WOOF WOOF"); + } +} \ No newline at end of file diff --git a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/EmbeddedBean.java b/src/test/java/org/jeasy/random/records/SupplyCrate.java similarity index 62% rename from easy-random-bean-validation/src/test/java/org/jeasy/random/validation/EmbeddedBean.java rename to src/test/java/org/jeasy/random/records/SupplyCrate.java index 92aa75205..0016647e8 100644 --- a/easy-random-bean-validation/src/test/java/org/jeasy/random/validation/EmbeddedBean.java +++ b/src/test/java/org/jeasy/random/records/SupplyCrate.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,32 +21,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.jeasy.random.validation; +package org.jeasy.random.records; -import java.util.List; +public class SupplyCrate { -import javax.validation.constraints.Size; + private String crateCode; + private int itemCount; + private AccessBadge accessBadge; -public class EmbeddedBean { + public SupplyCrate() { + } - private List items; + public String getCrateCode() { + return crateCode; + } - @Size(min = 3, max = 5) - private List otherItems; + public void setCrateCode(String crateCode) { + this.crateCode = crateCode; + } - public List getItems() { - return items; + public int getItemCount() { + return itemCount; } - public List getOtherItems() { - return otherItems; + public void setItemCount(int itemCount) { + this.itemCount = itemCount; } - public void setItems(List items) { - this.items = items; + public AccessBadge getAccessBadge() { + return accessBadge; } - public void setOtherItems(List otherItems) { - this.otherItems = otherItems; + public void setAccessBadge(AccessBadge accessBadge) { + this.accessBadge = accessBadge; } } diff --git a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NotBlankAnnotationHandler.java b/src/test/java/org/jeasy/random/records/WeatherWindow.java similarity index 59% rename from easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NotBlankAnnotationHandler.java rename to src/test/java/org/jeasy/random/records/WeatherWindow.java index 90930eebc..d29ff12f3 100644 --- a/easy-random-bean-validation/src/main/java/org/jeasy/random/validation/NotBlankAnnotationHandler.java +++ b/src/test/java/org/jeasy/random/records/WeatherWindow.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,24 +21,38 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.jeasy.random.validation; +package org.jeasy.random.records; -import org.jeasy.random.api.Randomizer; -import org.jeasy.random.randomizers.text.StringRandomizer; +public class WeatherWindow { -import java.lang.reflect.Field; -import java.util.Random; + private String forecastCode; + private String windStatus; + private String visibilityStatus; -class NotBlankAnnotationHandler implements BeanValidationAnnotationHandler { + public WeatherWindow() { + } + + public String getForecastCode() { + return forecastCode; + } + + public void setForecastCode(String forecastCode) { + this.forecastCode = forecastCode; + } + + public String getWindStatus() { + return windStatus; + } - private final Random random; + public void setWindStatus(String windStatus) { + this.windStatus = windStatus; + } - NotBlankAnnotationHandler(final long seed) { - random = new Random(seed); + public String getVisibilityStatus() { + return visibilityStatus; } - @Override - public Randomizer getRandomizer(Field field) { - return new StringRandomizer(random.nextLong()); + public void setVisibilityStatus(String visibilityStatus) { + this.visibilityStatus = visibilityStatus; } } diff --git a/easy-random-core/src/test/java/org/jeasy/random/util/CharacterUtilsTest.java b/src/test/java/org/jeasy/random/util/CharacterUtilsTest.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/util/CharacterUtilsTest.java rename to src/test/java/org/jeasy/random/util/CharacterUtilsTest.java index ff2bcf4e0..a9cd924af 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/util/CharacterUtilsTest.java +++ b/src/test/java/org/jeasy/random/util/CharacterUtilsTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/easy-random-core/src/test/java/org/jeasy/random/util/ReflectionUtilsTest.java b/src/test/java/org/jeasy/random/util/ReflectionUtilsTest.java similarity index 95% rename from easy-random-core/src/test/java/org/jeasy/random/util/ReflectionUtilsTest.java rename to src/test/java/org/jeasy/random/util/ReflectionUtilsTest.java index bf13d2ce8..283fb819f 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/util/ReflectionUtilsTest.java +++ b/src/test/java/org/jeasy/random/util/ReflectionUtilsTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,6 @@ import java.lang.annotation.Target; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.math.BigDecimal; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.DelayQueue; @@ -50,14 +49,7 @@ class ReflectionUtilsTest { @Test void testGetDeclaredFields() { - BigDecimal javaVersion = new BigDecimal(System.getProperty("java.specification.version")); - if (javaVersion.compareTo(new BigDecimal("12")) >= 0) { - assertThat(ReflectionUtils.getDeclaredFields(Street.class)).hasSize(21); - } else if (javaVersion.compareTo(new BigDecimal("9")) >= 0) { - assertThat(ReflectionUtils.getDeclaredFields(Street.class)).hasSize(22); - } else { - assertThat(ReflectionUtils.getDeclaredFields(Street.class)).hasSize(20); - } + assertThat(ReflectionUtils.getDeclaredFields(Street.class)).hasSize(3); } @Test diff --git a/easy-random-core/src/test/java/org/jeasy/random/visibility/VisibilityTest.java b/src/test/java/org/jeasy/random/visibility/VisibilityTest.java similarity index 96% rename from easy-random-core/src/test/java/org/jeasy/random/visibility/VisibilityTest.java rename to src/test/java/org/jeasy/random/visibility/VisibilityTest.java index 28f133bff..347ade58e 100644 --- a/easy-random-core/src/test/java/org/jeasy/random/visibility/VisibilityTest.java +++ b/src/test/java/org/jeasy/random/visibility/VisibilityTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2020, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) + * Copyright (c) 2023, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal