Polish contribution
See gh-23895
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.format.Formatter;
|
||||
* (which is commonly used for HTTP date header values), as of Spring 4.3.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Andrei Nevedomskii
|
||||
* @since 4.0
|
||||
* @see java.time.Instant#parse
|
||||
* @see java.time.format.DateTimeFormatter#ISO_INSTANT
|
||||
|
||||
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andrei Nevedomskii
|
||||
* @author Sam Brannen
|
||||
* @since 5.2.2
|
||||
* @since 5.1.12
|
||||
*/
|
||||
@DisplayName("InstantFormatter unit tests")
|
||||
@DisplayNameGeneration(ReplaceUnderscores.class)
|
||||
@@ -79,6 +79,27 @@ class InstantFormatterTests {
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
}
|
||||
|
||||
private static class RandomInstantProvider implements ArgumentsProvider {
|
||||
|
||||
private static final long DATA_SET_SIZE = 10;
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public final Stream<Arguments> provideArguments(ExtensionContext context) {
|
||||
return provideArguments().map(Arguments::of).limit(DATA_SET_SIZE);
|
||||
}
|
||||
|
||||
Stream<?> provideArguments() {
|
||||
return randomInstantStream(MIN, MAX);
|
||||
}
|
||||
|
||||
Stream<Instant> randomInstantStream(Instant min, Instant max) {
|
||||
return Stream.concat(Stream.of(Instant.now()), // make sure that the data set includes current instant
|
||||
random.longs(min.getEpochSecond(), max.getEpochSecond()).mapToObj(Instant::ofEpochSecond));
|
||||
}
|
||||
}
|
||||
|
||||
private static class ISOSerializedInstantProvider extends RandomInstantProvider {
|
||||
|
||||
@Override
|
||||
@@ -101,25 +122,4 @@ class InstantFormatterTests {
|
||||
}
|
||||
}
|
||||
|
||||
private static class RandomInstantProvider implements ArgumentsProvider {
|
||||
|
||||
private static final long DATA_SET_SIZE = 10;
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
Stream<?> provideArguments() {
|
||||
return randomInstantStream(MIN, MAX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return provideArguments().map(Arguments::of).limit(DATA_SET_SIZE);
|
||||
}
|
||||
|
||||
Stream<Instant> randomInstantStream(Instant min, Instant max) {
|
||||
return Stream.concat(Stream.of(Instant.now()), // make sure that the data set includes current instant
|
||||
random.longs(min.getEpochSecond(), max.getEpochSecond()).mapToObj(Instant::ofEpochSecond));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user