question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add TemporalAccessorAssert

See original GitHub issue

Summary

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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
scordiocommented, Mar 10, 2022

This is a terribly misdescribed issue. Sorry @scordio

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.

1reaction
scordiocommented, Mar 9, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found