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 more basic assertions for Local(Date|Time)

See original GitHub issue

Summary

It would be nice if AbstractLocal(Date|Time)Assert has basic assertions for field values of actual.

LocalDate

  • hasYear - 9dc086d82aa58a755f36cf88449b0ca74288bb63
  • hasMonth / hasMonthValue - 40c979c253571743af8d68f18921a061e10cfcec
  • hasDayOfMonth - 253194d00395e1568e1be752b0075c2033672f97

LocalTime

  • hasHour - 8c54e417b697314e55170668bd96c236fa3c96d6
  • hasMinute - ec1fcaefb767d0ed18a7e6ea48779c78635d1399
  • hasSecond - 6a4e54cbad5198246ae41a21d8432c503b5c70ce
  • hasNano - b756459

LocalDateTime

  • hasYear - 710177b
  • hasMonth / hasMonthValue - d0c87895c2a052473e8c4a7800fa7fee0a20dccb
  • hasDayOfMonth - 710177b
  • hasHour - 7cbe45c42f0a31bc5993a8352cf5e0d4feda0fae
  • hasMinute - 02fa4a9ab
  • hasSecond - 99e4f652cecc6f4492a0aec7bcfc7e97518a032a
  • hasNano - 76012bb

Examples

  final LocalDate actual = LocalDate.now();
  assertThat(actual).hasYear(actual.getYear());
  assertThat(actual).hasMonth(actual.getMonth());
  assertThat(actual).hasMonthValue(actual.getMonthValue());
  assertThat(actual).hasDayOfMonth(actual.getDayOfMonth());

  final LocalTime actual = LocalTime.now();
  assertThat(actual).hasHour(actual.getHour());
  assertThat(actual).hasMinute(actual.getMinute());
  assertThat(actual).hasSecond(actual.getSecond());
  assertThat(actual).hasNano(actual.getNano());

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:25 (25 by maintainers)

github_iconTop GitHub Comments

3reactions
joel-costigliolacommented, Apr 12, 2022

@jessicant this why @onacit has suggested having two assertions for month that matches the LocalDate API

Use int for hasMonthValue and Month for hasMonth.

@onacit correct me if I’m wrong 😉

3reactions
joel-costigliolacommented, Apr 10, 2022

thanks @jessicant, this issue being big I split it into tasks so that multiple contributors can work on it, they should as you did indicate which assertions they want to work on. the integrated commit can be used as a reference for implementing the other assertions: 9dc086d82aa58a755f36cf88449b0ca74288bb63

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add more basic assertions for Local(Date|Time) #2541 - GitHub
Summary It would be nice if AbstractLocal(Date|Time)Assert has basic assertions for field values of actual.
Read more >
Dates & Times - Fluent Assertions
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit...
Read more >
java - Compare Date objects with different levels of precision
Starting with version 3.7.0, AssertJ added an isCloseTo assertions, if you are using the Java 8 Date / Time API. LocalTime _07_10 =...
Read more >
AssertJ's Java 8 Features - Baeldung
The LocalDateTime assertions work similarly to LocalDate's, but do not share the isToday method. Let's create an example LocalDateTime object:
Read more >
AssertJ - fluent assertions java library - GitHub Pages
A Joda Time module to provide assertions for Joda Time types (DateTime, LocalDateTime). A Neo4J module to provide assertions for Neo4J types (Path,...
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