Add TemporalAccessorAssert
See original GitHub issueSummary
It seems the TemporalAccessor
interface may have it’s corresponding (abstract) assert.
Example
abstract class AbstractTemporalAccessorAssert<
SELF extends AbstractTemporalAccessor<T, SELF>,
T extends TemporalAccessor>
extends AbstractTemporalAssert<SELF, T> {
}
Existing assert classes may be refactored extending this class.
abstract class AbstractLocalDateAssert<SELF extends AbstractLocalDateAssert<SELF>>
//extends AbstractTemporalAssert<SELF, LocalDate>
extends AbstractTemporalAccessorAssert<SELF, LocalDate>
TemporalAccessor actual = LocalDateTime.now();
assertThat(actual)
.hasFieldSatisfying(ChornoField.YEAR, y -> { // get(TemporalField) -> IntConsumer
assertThat(y).isEqualTo(2022);
})
.hasLongFieldSatisfying(ChrooField.WHATEVER, l -> { // getLong(TemporalField) -> LongConsumer
})
.isSupported(ChronoField.WHATEVER)
.hasResultSatisfying(TemporalQuery<R> query, Consumer<? super R> c)
.hasRangeSatisfying(r -> {
assertThat(r)...; // ValueRangeAssert?
assertThat(r.getMaximum()).isEqualTo(...);
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Java SE 8 TemporalAccessor.from issues when used with a ...
Short answer: The JSR-310-designers don't want people to do conversions between machine time and human time via static from()-methods in types like ZoneId ......
Read more >java.time.temporal.TemporalAccessor.query java code ...
This queries this date-time using the specified query strategy object. Queries are a key tool for extracting information from date-times. They exists to ......
Read more >java.time.temporal.TemporalAccessor Java Examples
This page shows Java code examples of java.time.temporal.TemporalAccessor.
Read more >Better error messages for parsing · Issue #342 - GitHub
Assert.assertSame; +import static org.testng.Assert. ... exception method that can be added as a cause on the exception created by parse.
Read more >TemporalAccessor | Android Developers
TemporalAccessor. bookmark_border. Stay organized with collections Save and categorize content based on your preferences. Dismiss
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nothing to be sorry about, @onacit! We are happy to receive any kind of input especially because it’s hard to predict all the possible ways assertions could be used.
Do you have a concrete use case where you would use a
TemporalAccessor
variable and the assertions in your example?I’d expect the average usage of the date/time API is with the types provided by the JDK and you’d get already nicer assertions with those.