You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rc...@apache.org on 2020/05/04 10:01:49 UTC
[james-project] 02/14: [Refactoring] simplify test by leveraging
assertj support for java.time types
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit f24e9206cbb3d1a1009c2860244e88cf720134fd
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Tue Apr 28 21:24:02 2020 +0200
[Refactoring] simplify test by leveraging assertj support for java.time types
---
.../query/DateResolutionFormatterTest.java | 51 +++++++---------------
1 file changed, 15 insertions(+), 36 deletions(-)
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormatterTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormatterTest.java
index 4b6932c..3487439 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormatterTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/query/DateResolutionFormatterTest.java
@@ -30,69 +30,48 @@ import org.junit.jupiter.api.Test;
class DateResolutionFormatterTest {
- final String dateString = "2014-01-02T15:15:15Z";
+ final ZonedDateTime date = ZonedDateTime.parse("2014-01-02T15:15:15Z");
@Test
void calculateUpperDateShouldReturnDateUpToTheNextMinuteUsingMinuteUnit() {
- assertThat(
- ISO_OFFSET_DATE_TIME.format(
- DateResolutionFormatter.computeUpperDate(ZonedDateTime.parse(dateString, ISO_OFFSET_DATE_TIME), SearchQuery.DateResolution.Minute)
- )
- ).isEqualTo("2014-01-02T15:16:00Z");
+ assertThat(DateResolutionFormatter.computeUpperDate(date, SearchQuery.DateResolution.Minute))
+ .isEqualTo("2014-01-02T15:16:00Z");
}
@Test
void calculateUpperDateShouldReturnDateUpToTheNextHourUsingHourUnit() {
- assertThat(
- ISO_OFFSET_DATE_TIME.format(
- DateResolutionFormatter.computeUpperDate(ZonedDateTime.parse(dateString, ISO_OFFSET_DATE_TIME), SearchQuery.DateResolution.Hour)
- )
- ).isEqualTo("2014-01-02T16:00:00Z");
+ assertThat(DateResolutionFormatter.computeUpperDate(date, SearchQuery.DateResolution.Hour))
+ .isEqualTo("2014-01-02T16:00:00Z");
}
@Test
void calculateUpperDateShouldReturnDateUpToTheNextMonthUsingMonthUnit() {
- assertThat(
- ISO_OFFSET_DATE_TIME.format(
- DateResolutionFormatter.computeUpperDate(ZonedDateTime.parse(dateString, ISO_OFFSET_DATE_TIME), SearchQuery.DateResolution.Month)
- )
- ).isEqualTo("2014-02-01T00:00:00Z");
+ assertThat(DateResolutionFormatter.computeUpperDate(date, SearchQuery.DateResolution.Month))
+ .isEqualTo("2014-02-01T00:00:00Z");
}
@Test
void calculateUpperDateShouldReturnDateUpToTheNextYearUsingYearUnit() {
- assertThat(
- ISO_OFFSET_DATE_TIME.format(
- DateResolutionFormatter.computeUpperDate(ZonedDateTime.parse(dateString, ISO_OFFSET_DATE_TIME), SearchQuery.DateResolution.Year)
- )
- ).isEqualTo("2015-01-01T00:00:00Z");
+ assertThat(DateResolutionFormatter.computeUpperDate(date, SearchQuery.DateResolution.Year))
+ .isEqualTo("2015-01-01T00:00:00Z");
}
@Test
void calculateUpperDateShouldReturnDateUpToTheNextDayUsingDayUnit() {
- assertThat(
- ISO_OFFSET_DATE_TIME.format(
- DateResolutionFormatter.computeUpperDate(ZonedDateTime.parse(dateString, ISO_OFFSET_DATE_TIME), SearchQuery.DateResolution.Day)
- )
- ).isEqualTo("2014-01-03T00:00:00Z");
+ assertThat(DateResolutionFormatter.computeUpperDate(date, SearchQuery.DateResolution.Day))
+ .isEqualTo("2014-01-03T00:00:00Z");
}
@Test
void calculateLowerDateShouldReturnDateUpToThePreviousMinuteUsingMinuteUnit() {
- assertThat(
- ISO_OFFSET_DATE_TIME.format(
- DateResolutionFormatter.computeLowerDate(ZonedDateTime.parse(dateString, ISO_OFFSET_DATE_TIME), SearchQuery.DateResolution.Minute)
- )
- ).isEqualTo("2014-01-02T15:15:00Z");
+ assertThat(DateResolutionFormatter.computeLowerDate(date, SearchQuery.DateResolution.Minute))
+ .isEqualTo("2014-01-02T15:15:00Z");
}
@Test
void calculateLowerDateShouldReturnDateUpToThePreviousDayUsingDayUnit() {
- assertThat(
- ISO_OFFSET_DATE_TIME.format(
- DateResolutionFormatter.computeLowerDate(ZonedDateTime.parse(dateString, ISO_OFFSET_DATE_TIME), SearchQuery.DateResolution.Day)
- )
- ).isEqualTo("2014-01-02T00:00:00Z");
+ assertThat(DateResolutionFormatter.computeLowerDate(date, SearchQuery.DateResolution.Day))
+ .isEqualTo("2014-01-02T00:00:00Z");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org