You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set limit interval for LocalDateRangeRandomizer as [today-1, today+1]
Generate data on a large scale: e.g. 500.000 records
Validate that upper interval limit: today+1 is added in the generated list
Actual Results:
The upper interval limit: today+1 is not added in the generated list
Expected Results:
The upper interval limit: today+1 should be added in the generated list
Test example:
import org.jeasy.random.EasyRandomParameters;
import org.jeasy.random.randomizers.range.LocalDateRangeRandomizer;
import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
public class LocalDateRandomizerTest {
EasyRandomParameters easyRandomParameters;
LocalDate minDate;
LocalDate maxDate;
LocalDate date;
final int SEARCH_INTERVAL = 500000;
@Test
public void testLocalDateRandomizerLimits() {
easyRandomParameters = new EasyRandomParameters();
minDate = LocalDate.now().minusDays(1);
maxDate = LocalDate.now().plusDays(1);
LocalDateRangeRandomizer randomizer = new LocalDateRangeRandomizer(minDate,maxDate);
List<LocalDate> localDates = new ArrayList<>();
for (int i = 0; i < SEARCH_INTERVAL; i++) {
date = randomizer.getRandomValue();
localDates.add(date);
}
Assert.assertTrue("Upper limit interval can not be found in the generated list", localDates.contains(maxDate));
}
}
Test Results: Results: java.lang.AssertionError: Upper limit interval can not be found in the generated list
The text was updated successfully, but these errors were encountered:
Thank you for opening this issue, which is actually a documentation issue. The min is inclusive and the max is exclusive (Easy Random uses a formula similar to ThreadLocalRandom.current().nextDouble(min, max) where the max is exclusive). I updated the javadocs accordingly.
fmbenhassine
changed the title
LocalDateRangeRandomizer- upper limit not being added in the random generated list
Update Javadocs of range randomizers about range boundaries
Oct 16, 2020
Version: 4.2.0
Steps to reproduce:
Actual Results:
The upper interval limit: today+1 is not added in the generated list
Expected Results:
The upper interval limit: today+1 should be added in the generated list
Test example:
Test Results:
Results: java.lang.AssertionError: Upper limit interval can not be found in the generated list
The text was updated successfully, but these errors were encountered: