From 7f0d3119a549a017c9bd3c90ed2e02e506d9c17c Mon Sep 17 00:00:00 2001 From: Ryan Stuart Date: Tue, 5 Nov 2019 12:57:14 +0000 Subject: [PATCH 1/3] fix(#1517): Fix random upper bound At some point the restrictions were changed from being (inclusive or exclusive) to all being inclusive. The random generators didn't receive this update. I chose the easier fix of keeping the random generators using (inclusive lower, exclusive upper) bounds and fixing the interfacing point to respect this by adding on one unit to the upper bound. ie. [0, 2] -> [0, 3) This works because we always have a minimum unit specified, and changing this behaviour would have wider implications across our codebase. --- .../generation/fieldvaluesources/LinearFieldValueSource.java | 5 ++++- .../deg/generator/utils/JavaUtilRandomNumberGenerator.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/generator/src/main/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSource.java b/generator/src/main/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSource.java index 252d2b0be..4e96f8286 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSource.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSource.java @@ -54,7 +54,10 @@ public Stream generateInterestingValues() { @Override public Stream generateRandomValues(RandomNumberGenerator randomNumberGenerator) { return Stream.generate(() -> restrictions.getGranularity() - .getRandom(restrictions.getMin(), restrictions.getMax(), randomNumberGenerator)) + .getRandom( + restrictions.getMin(), + restrictions.getGranularity().getNext(restrictions.getMax()), + randomNumberGenerator)) .filter(this::notInBlacklist); } diff --git a/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java b/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java index 1ecff86c5..ef24b1729 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java @@ -17,7 +17,6 @@ package com.scottlogic.deg.generator.utils; import java.math.BigDecimal; -import java.math.RoundingMode; import java.util.Random; public class JavaUtilRandomNumberGenerator implements RandomNumberGenerator { @@ -71,8 +70,9 @@ public double nextDouble(double lowerInclusive, double upperExclusive) { @Override public BigDecimal nextBigDecimal(BigDecimal lowerInclusive, BigDecimal upperExclusive) { - return new BigDecimal(random.nextDouble()) + return BigDecimal.valueOf(random.nextDouble()) .multiply(upperExclusive.subtract(lowerInclusive)) .add(lowerInclusive); } + } From 91d7b927918219ff6cb57e48a8bbc4427923d83b Mon Sep 17 00:00:00 2001 From: Ryan Stuart Date: Tue, 5 Nov 2019 14:15:49 +0000 Subject: [PATCH 2/3] Add test to show the entry to the random number generator correctly converts from an inclusive upper bound to an exclusive upper bound. --- .../LinearFieldValueSourceTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSourceTest.java diff --git a/generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSourceTest.java b/generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSourceTest.java new file mode 100644 index 000000000..08f93a673 --- /dev/null +++ b/generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSourceTest.java @@ -0,0 +1,29 @@ +package com.scottlogic.deg.generator.generation.fieldvaluesources; + +import com.scottlogic.deg.common.profile.NumericGranularity; +import com.scottlogic.deg.generator.restrictions.linear.LinearRestrictions; +import com.scottlogic.deg.generator.utils.JavaUtilRandomNumberGenerator; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.*; + +class LinearFieldValueSourceTest { + + @Test + public void testGenerateRandomValues() { + LinearRestrictions restrictions = new LinearRestrictions<>( + BigDecimal.ZERO, + BigDecimal.valueOf(4), + new NumericGranularity(0)); + LinearFieldValueSource source = new LinearFieldValueSource<>(restrictions, Collections.emptySet()); + + Stream results = source.generateRandomValues(new JavaUtilRandomNumberGenerator()); + + assertTrue(results.limit(100).allMatch(x -> x.intValue() >= 0 & x.intValue() < 5)); + } + +} \ No newline at end of file From a9a969b984eb6fe7f514aec38d6971c94918fb75 Mon Sep 17 00:00:00 2001 From: Ryan Stuart Date: Wed, 6 Nov 2019 11:13:54 +0000 Subject: [PATCH 3/3] Fix tests, tidy warnings. Fixed DateTimeFieldValueSourceTests, which previously assumed that 1 was a valid result from a random number generator generating in the range [0,1). This has been fixed to use a value sufficiently close to one. Also tidied various compiler warnings in the test, and modified an unused method in the random number generator to be useful. --- .../common/profile/DateTimeGranularity.java | 2 +- .../utils/RandomNumberGenerator.java | 2 +- .../testUtils/TestRandomNumberGenerator.java | 7 +- .../utils/JavaUtilRandomNumberGenerator.java | 25 ++---- .../DateTimeFieldValueSourceTests.java | 77 ++++++++++--------- 5 files changed, 51 insertions(+), 62 deletions(-) diff --git a/common/src/main/java/com/scottlogic/deg/common/profile/DateTimeGranularity.java b/common/src/main/java/com/scottlogic/deg/common/profile/DateTimeGranularity.java index 70d4134c8..f3c4b969b 100644 --- a/common/src/main/java/com/scottlogic/deg/common/profile/DateTimeGranularity.java +++ b/common/src/main/java/com/scottlogic/deg/common/profile/DateTimeGranularity.java @@ -82,7 +82,7 @@ public OffsetDateTime getPrevious(OffsetDateTime value) { @Override public OffsetDateTime getRandom(OffsetDateTime min, OffsetDateTime max, RandomNumberGenerator randomNumberGenerator) { - long generatedLong = (long) randomNumberGenerator.nextDouble(getMilli(min), getMilli(max)); + long generatedLong = randomNumberGenerator.nextLong(getMilli(min), getMilli(max)); OffsetDateTime generatedDate = Instant.ofEpochMilli(generatedLong).atZone(ZoneOffset.UTC).toOffsetDateTime(); diff --git a/common/src/main/java/com/scottlogic/deg/generator/utils/RandomNumberGenerator.java b/common/src/main/java/com/scottlogic/deg/generator/utils/RandomNumberGenerator.java index 7c2c471fd..95a07de06 100644 --- a/common/src/main/java/com/scottlogic/deg/generator/utils/RandomNumberGenerator.java +++ b/common/src/main/java/com/scottlogic/deg/generator/utils/RandomNumberGenerator.java @@ -21,7 +21,7 @@ public interface RandomNumberGenerator { int nextInt(); int nextInt(int bound); - int nextInt(int lowerInclusive, int upperExclusive); + long nextLong(long lowerInclusive, long upperInclusive); double nextDouble(double lowerInclusive, double upperExclusive); BigDecimal nextBigDecimal(BigDecimal lowerInclusive, BigDecimal upperExclusive); } diff --git a/common/src/test/java/com/scottlogic/deg/testUtils/TestRandomNumberGenerator.java b/common/src/test/java/com/scottlogic/deg/testUtils/TestRandomNumberGenerator.java index fef31d3ac..5f23d9d63 100644 --- a/common/src/test/java/com/scottlogic/deg/testUtils/TestRandomNumberGenerator.java +++ b/common/src/test/java/com/scottlogic/deg/testUtils/TestRandomNumberGenerator.java @@ -39,8 +39,9 @@ public int nextInt(int bound) { } @Override - public int nextInt(int lowerInclusive, int upperExclusive) { - return 0; + public long nextLong(long lowerInclusive, long upperExclusive) { + long multiplier = (long) (nextDoubleValue * (double) (upperExclusive - lowerInclusive)); + return multiplier + lowerInclusive; } @Override @@ -50,6 +51,6 @@ public double nextDouble(double lower, double upper) { @Override public BigDecimal nextBigDecimal(BigDecimal lowerInclusive, BigDecimal upperExclusive) { - return new BigDecimal(nextDouble(lowerInclusive.doubleValue(), upperExclusive.doubleValue())); + return BigDecimal.valueOf(nextDouble(lowerInclusive.doubleValue(), upperExclusive.doubleValue())); } } \ No newline at end of file diff --git a/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java b/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java index ef24b1729..1bd4bb8fd 100644 --- a/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java +++ b/generator/src/main/java/com/scottlogic/deg/generator/utils/JavaUtilRandomNumberGenerator.java @@ -41,30 +41,15 @@ public int nextInt(int bound) { } @Override - public int nextInt(int lowerInclusive, int upperExclusive) { - // implementation copied from Random::internalNextInt - if (lowerInclusive < upperExclusive) { - int n = upperExclusive - lowerInclusive; - if (n > 0) { - return nextInt(n) + lowerInclusive; - } - else { // range not representable as int - int r; - do { - r = nextInt(); - } while (r < lowerInclusive || r >= upperExclusive); - return r; - } - } - else { - return nextInt(); - } + public long nextLong(long lowerInclusive, long upperExclusive) { + long multiplier = (long) (random.nextDouble() * (double) (upperExclusive - lowerInclusive)); + return multiplier + lowerInclusive; } @Override public double nextDouble(double lowerInclusive, double upperExclusive) { - return random.nextDouble() - * (upperExclusive - lowerInclusive) + return (random.nextDouble() + * (upperExclusive - lowerInclusive)) + lowerInclusive; } diff --git a/generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/datetime/DateTimeFieldValueSourceTests.java b/generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/datetime/DateTimeFieldValueSourceTests.java index f850d5f85..78eaeb745 100644 --- a/generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/datetime/DateTimeFieldValueSourceTests.java +++ b/generator/src/test/java/com/scottlogic/deg/generator/generation/fieldvaluesources/datetime/DateTimeFieldValueSourceTests.java @@ -42,9 +42,13 @@ public class DateTimeFieldValueSourceTests { + // Approximately one, but not definitively proven to be the closest possible float to one + // This is used due to the random range being [0,1), not [0,1] + private static final double ALMOST_ONE = 0.9999999996504378; + private Limit lowerLimit = DATETIME_MIN_LIMIT; private Limit upperLimit = DATETIME_MAX_LIMIT; - private Set blackList = new HashSet<>(); + private Set blackList = new HashSet<>(); private LinearFieldValueSource fieldSource; @Test @@ -63,7 +67,7 @@ public void whenGeneratingUnboundSetWithBlacklist() { @Test public void whenGivenUpperBound() { - givenUpperBound(createDate(2018, 01, 01), true); + givenUpperBound(createDate(2018, 1, 1), true); expectInterestingValues( ISO_MIN_DATE, createDate(2018, 1, 1)); @@ -71,7 +75,7 @@ public void whenGivenUpperBound() { @Test public void whenGivenLowerBound() { - givenLowerBound(createDate(2018, 01, 01), true); + givenLowerBound(createDate(2018, 1, 1), true); expectInterestingValues( createDate(2018, 1, 1), ISO_MAX_DATE); @@ -96,7 +100,7 @@ public void getRandomValues_withExclusiveUpperBound_shouldGenerateCorrectValues( givenUpperBound(OffsetDateTime.of(date.atTime(LocalTime.of(18, 0, 0)), ZoneOffset.UTC), false); LinearRestrictions restrictions = LinearRestrictionsFactory.createDateTimeRestrictions(lowerLimit, upperLimit); - fieldSource = new LinearFieldValueSource(restrictions, blackList); + fieldSource = new LinearFieldValueSource<>(restrictions, blackList); TestRandomNumberGenerator rng = new TestRandomNumberGenerator(); rng.setNextDouble(0); @@ -106,7 +110,7 @@ public void getRandomValues_withExclusiveUpperBound_shouldGenerateCorrectValues( Assert.assertThat(iterator.next(), equalTo(OffsetDateTime.of(date.atTime(LocalTime.of(12, 0, 0)), ZoneOffset.UTC))); - rng.setNextDouble(1); + rng.setNextDouble(ALMOST_ONE); // Because internally the filteringIterator pre-generates the first value before we can set // the new "random" value we have re-create the iterator @@ -120,7 +124,7 @@ public void getRandomValues_withExclusiveUpperBound_shouldGenerateCorrectValues( iterator = fieldSource.generateRandomValues(rng).iterator(); Assert.assertThat(iterator.next(), - equalTo(OffsetDateTime.of(date.atTime(LocalTime.of(14, 59, 59, 999_000_000)), ZoneOffset.UTC))); + equalTo(OffsetDateTime.of(date.atTime(LocalTime.of(15, 0, 0)), ZoneOffset.UTC))); } @@ -133,7 +137,7 @@ public void getRandomValues_withInclusiveUpperBound_shouldGenerateCorrectValues( LinearRestrictions restrictions = LinearRestrictionsFactory.createDateTimeRestrictions(lowerLimit, upperLimit); - fieldSource = new LinearFieldValueSource(restrictions, blackList); + fieldSource = new LinearFieldValueSource<>(restrictions, blackList); TestRandomNumberGenerator rng = new TestRandomNumberGenerator(); rng.setNextDouble(0); @@ -143,7 +147,7 @@ public void getRandomValues_withInclusiveUpperBound_shouldGenerateCorrectValues( Assert.assertThat(iterator.next(), equalTo(OffsetDateTime.of(date.atTime(LocalTime.of(12, 0, 0)), ZoneOffset.UTC))); - rng.setNextDouble(1); + rng.setNextDouble(ALMOST_ONE); // Because internally the filteringIterator pre-generates the first value before we can set // the new "random" value we have re-create the iterator @@ -168,7 +172,7 @@ public void getRandomValues_withExclusiveLowerBound_shouldGenerateCorrectValues( LinearRestrictions restrictions = LinearRestrictionsFactory.createDateTimeRestrictions(lowerLimit, upperLimit); - fieldSource = new LinearFieldValueSource(restrictions, blackList); + fieldSource = new LinearFieldValueSource<>(restrictions, blackList); TestRandomNumberGenerator rng = new TestRandomNumberGenerator(); rng.setNextDouble(0); @@ -178,7 +182,7 @@ public void getRandomValues_withExclusiveLowerBound_shouldGenerateCorrectValues( Assert.assertThat(iterator.next(), equalTo(OffsetDateTime.of(date.atTime(LocalTime.of(12, 0, 0, 1_000_000)), ZoneOffset.UTC))); - rng.setNextDouble(1); + rng.setNextDouble(ALMOST_ONE); // Because internally the filteringIterator pre-generates the first value before we can set // the new "random" value we have re-create the iterator @@ -192,7 +196,7 @@ public void getRandomValues_withExclusiveLowerBound_shouldGenerateCorrectValues( iterator = fieldSource.generateRandomValues(rng).iterator(); Assert.assertThat(iterator.next(), - equalTo(OffsetDateTime.of(date.atTime(LocalTime.of(15, 0, 0)), ZoneOffset.UTC))); + equalTo(OffsetDateTime.of(date.atTime(LocalTime.of(15, 0, 0, 1_000_000)), ZoneOffset.UTC))); } @Test @@ -201,23 +205,23 @@ public void getRandomValues_withSmallPermittedRangeAtEndOfLegalRange_shouldGener LinearRestrictions restrictions = LinearRestrictionsFactory.createDateTimeRestrictions(lowerLimit, upperLimit); - fieldSource = new LinearFieldValueSource(restrictions, blackList); + fieldSource = new LinearFieldValueSource<>(restrictions, blackList); TestRandomNumberGenerator rng = new TestRandomNumberGenerator(); - rng.setNextDouble(0.99); + rng.setNextDouble(ALMOST_ONE); Iterator iterator = fieldSource.generateRandomValues(rng).iterator(); Assert.assertThat(iterator.next(), - equalTo(OffsetDateTime.of(9999, 12, 31, 23, 59, 23, 999_000_000, ZoneOffset.UTC))); + equalTo(OffsetDateTime.of(9999, 12, 31, 23, 59, 59, 999_000_000, ZoneOffset.UTC))); } @Test public void shouldBeEqualWhenAllPropertiesMatch(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); @@ -227,10 +231,10 @@ public void shouldBeEqualWhenAllPropertiesMatch(){ @Test public void shouldBeEqualWhenAllPropertiesMatchWhenBlacklistInDifferentOrder(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MAX, OffsetDateTime.MIN))); @@ -240,10 +244,10 @@ public void shouldBeEqualWhenAllPropertiesMatchWhenBlacklistInDifferentOrder(){ @Test public void shouldBeEqualWhenAllPropertiesMatchWhenBlacklistEmpty(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), Collections.emptySet()); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), Collections.emptySet()); @@ -253,10 +257,10 @@ public void shouldBeEqualWhenAllPropertiesMatchWhenBlacklistEmpty(){ @Test public void shouldBeUnequalWhenAllPropertiesMatchExceptMin(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-28", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); @@ -265,10 +269,10 @@ public void shouldBeUnequalWhenAllPropertiesMatchExceptMin(){ @Test public void shouldBeUnequalWhenAllPropertiesMatchExceptMax(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-30"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); @@ -277,10 +281,10 @@ public void shouldBeUnequalWhenAllPropertiesMatchExceptMax(){ @Test public void shouldBeUnequalWhenAllPropertiesMatchExceptBlacklist(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Collections.singletonList(OffsetDateTime.MIN))); @@ -289,10 +293,10 @@ public void shouldBeUnequalWhenAllPropertiesMatchExceptBlacklist(){ @Test public void shouldBeUnequalWhenOnlyBlacklistMatches(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-28", "2010-11-30"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); @@ -301,10 +305,10 @@ public void shouldBeUnequalWhenOnlyBlacklistMatches(){ @Test public void shouldBeUnequalWhenAllPropertiesDontMatch(){ - LinearFieldValueSource a = new LinearFieldValueSource( + LinearFieldValueSource a = new LinearFieldValueSource<>( restrictions("2001-02-28", "2010-11-30"), new HashSet<>(Arrays.asList(OffsetDateTime.MIN, OffsetDateTime.MAX))); - LinearFieldValueSource b = new LinearFieldValueSource( + LinearFieldValueSource b = new LinearFieldValueSource<>( restrictions("2001-02-03", "2010-11-12"), new HashSet<>(Collections.singletonList(OffsetDateTime.MIN))); @@ -319,7 +323,7 @@ public void datetimeGenerateAllValues_withMinSetToMaxDate_emitsNoValues(){ DATETIME_MAX_LIMIT ); - LinearFieldValueSource datesAfterLastPermittedDate = new LinearFieldValueSource(min, Collections.emptySet()); + LinearFieldValueSource datesAfterLastPermittedDate = new LinearFieldValueSource<>(min, Collections.emptySet()); //Act Iterator iterator = datesAfterLastPermittedDate.generateAllValues().iterator(); @@ -334,7 +338,7 @@ public void datetimeGenerateAllValues_withMaxSetToMinDate_emitsNoValues(){ DATETIME_MIN_LIMIT, new Limit<>(ISO_MIN_DATE, false) ); - LinearFieldValueSource datesBeforeFirstPermittedDate = new LinearFieldValueSource(max, Collections.emptySet()); + LinearFieldValueSource datesBeforeFirstPermittedDate = new LinearFieldValueSource<>(max, Collections.emptySet()); //Act Iterator iterator = datesBeforeFirstPermittedDate.generateAllValues().iterator(); @@ -343,11 +347,10 @@ public void datetimeGenerateAllValues_withMaxSetToMinDate_emitsNoValues(){ } private LinearRestrictions restrictions(String min, String max){ - LinearRestrictions restrictions = LinearRestrictionsFactory.createDateTimeRestrictions( + return LinearRestrictionsFactory.createDateTimeRestrictions( min == null ? null : getTimeLimit(min), max == null ? null : getTimeLimit(max) ); - return restrictions; } private Limit getTimeLimit(String dateString) { @@ -366,7 +369,7 @@ private void givenUpperBound(OffsetDateTime value, boolean inclusive) { upperLimit = new Limit<>(value, inclusive); } - private void givenBlacklist(Object... list) { + private void givenBlacklist(OffsetDateTime... list) { blackList = new HashSet<>(Arrays.asList(list)); } @@ -375,7 +378,7 @@ private void expectAllValues(Object... expectedValuesArray) { List actualValues = new ArrayList<>(); LinearRestrictions restrictions = LinearRestrictionsFactory.createDateTimeRestrictions(lowerLimit, upperLimit); - fieldSource = new LinearFieldValueSource(restrictions, blackList); + fieldSource = new LinearFieldValueSource<>(restrictions, blackList); fieldSource.generateAllValues().forEach(actualValues::add); @@ -388,7 +391,7 @@ private void expectInterestingValues(Object... expectedValuesArray) { LinearRestrictions restrictions = LinearRestrictionsFactory.createDateTimeRestrictions(lowerLimit, upperLimit); - fieldSource = new LinearFieldValueSource(restrictions, blackList); + fieldSource = new LinearFieldValueSource<>(restrictions, blackList); fieldSource.generateInterestingValues().forEach(actualValues::add);