Skip to content

Commit 625b7ef

Browse files
committed
Rename
1 parent dbdb775 commit 625b7ef

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

driver-core/src/test/functional/com/mongodb/client/model/expressions/DateExpressionsFunctionalTest.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@
3030
class DateExpressionsFunctionalTest extends AbstractExpressionsFunctionalTest {
3131
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/#date-expression-operators
3232

33-
private final ZonedDateTime utcDateTime = ZonedDateTime.ofInstant(Instant.parse("2007-12-03T10:15:30.005Z"), ZoneId.of(ZoneOffset.UTC.getId()));
33+
private final Instant instant = Instant.parse("2007-12-03T10:15:30.005Z");
34+
private final DateExpression date = of(instant);
35+
private final ZonedDateTime utcDateTime = ZonedDateTime.ofInstant(instant, ZoneId.of(ZoneOffset.UTC.getId()));
3436
private final StringExpression utc = of("UTC");
35-
private final DateExpression utcDateEx = of(utcDateTime.toInstant());
3637

3738
@Test
3839
public void literalsTest() {
3940
assertExpression(
40-
utcDateTime.toInstant(), utcDateEx,
41+
instant,
42+
date,
4143
"{'$date': '2007-12-03T10:15:30.005Z'}");
4244
}
4345

@@ -46,7 +48,7 @@ public void yearTest() {
4648
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/
4749
assertExpression(
4850
utcDateTime.get(ChronoField.YEAR),
49-
utcDateEx.year(utc),
51+
date.year(utc),
5052
"{'$year': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
5153
}
5254

@@ -55,7 +57,7 @@ public void monthTest() {
5557
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/
5658
assertExpression(
5759
utcDateTime.get(ChronoField.MONTH_OF_YEAR),
58-
utcDateEx.month(utc),
60+
date.month(utc),
5961
"{'$month': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
6062
}
6163

@@ -64,7 +66,7 @@ public void dayOfMonthTest() {
6466
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/
6567
assertExpression(
6668
utcDateTime.get(ChronoField.DAY_OF_MONTH),
67-
utcDateEx.dayOfMonth(utc),
69+
date.dayOfMonth(utc),
6870
"{'$dayOfMonth': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
6971
}
7072

@@ -73,7 +75,7 @@ public void dayOfWeekTest() {
7375
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/
7476
assertExpression(
7577
utcDateTime.get(ChronoField.DAY_OF_WEEK) + 1,
76-
utcDateEx.dayOfWeek(utc),
78+
date.dayOfWeek(utc),
7779
"{'$dayOfWeek': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
7880
}
7981

@@ -82,7 +84,7 @@ public void dayOfYearTest() {
8284
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/
8385
assertExpression(
8486
utcDateTime.get(ChronoField.DAY_OF_YEAR),
85-
utcDateEx.dayOfYear(utc),
87+
date.dayOfYear(utc),
8688
"{'$dayOfYear': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
8789
}
8890

@@ -91,7 +93,7 @@ public void hourTest() {
9193
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/
9294
assertExpression(
9395
utcDateTime.get(ChronoField.HOUR_OF_DAY),
94-
utcDateEx.hour(utc),
96+
date.hour(utc),
9597
"{'$hour': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
9698
}
9799

@@ -100,7 +102,7 @@ public void minuteTest() {
100102
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/
101103
assertExpression(
102104
utcDateTime.get(ChronoField.MINUTE_OF_HOUR),
103-
utcDateEx.minute(utc),
105+
date.minute(utc),
104106
"{'$minute': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
105107
}
106108

@@ -109,7 +111,7 @@ public void secondTest() {
109111
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/
110112
assertExpression(
111113
utcDateTime.get(ChronoField.SECOND_OF_MINUTE),
112-
utcDateEx.second(utc),
114+
date.second(utc),
113115
"{'$second': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
114116
}
115117

@@ -118,7 +120,7 @@ public void weekTest() {
118120
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/
119121
assertExpression(
120122
48,
121-
utcDateEx.week(utc),
123+
date.week(utc),
122124
"{'$week': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
123125
}
124126

@@ -127,27 +129,27 @@ public void millisecondTest() {
127129
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/
128130
assertExpression(
129131
utcDateTime.get(ChronoField.MILLI_OF_SECOND),
130-
utcDateEx.millisecond(utc),
132+
date.millisecond(utc),
131133
"{'$millisecond': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, 'timezone': 'UTC'}}");
132134
}
133135

134136
@Test
135137
public void dateToStringTest() {
136138
// https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/
137139
assertExpression(
138-
utcDateTime.toInstant().toString(),
139-
utcDateEx.dateToString(),
140+
instant.toString(),
141+
date.dateToString(),
140142
"{'$dateToString': {'date': {'$date': '2007-12-03T10:15:30.005Z'}}}");
141143
// with parameters
142144
assertExpression(
143145
utcDateTime.withZoneSameInstant(ZoneId.of("America/New_York")).format(ISO_LOCAL_DATE_TIME),
144-
utcDateEx.dateToString(of("America/New_York"), of("%Y-%m-%dT%H:%M:%S.%L")),
146+
date.dateToString(of("America/New_York"), of("%Y-%m-%dT%H:%M:%S.%L")),
145147
"{'$dateToString': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, "
146148
+ "'format': '%Y-%m-%dT%H:%M:%S.%L', "
147149
+ "'timezone': 'America/New_York'}}");
148150
assertExpression(
149151
utcDateTime.withZoneSameInstant(ZoneId.of("+04:30")).format(ISO_LOCAL_DATE_TIME),
150-
utcDateEx.dateToString(of("+04:30"), of("%Y-%m-%dT%H:%M:%S.%L")),
152+
date.dateToString(of("+04:30"), of("%Y-%m-%dT%H:%M:%S.%L")),
151153
"{'$dateToString': {'date': {'$date': '2007-12-03T10:15:30.005Z'}, "
152154
+ "'format': '%Y-%m-%dT%H:%M:%S.%L', "
153155
+ "'timezone': '+04:30'}}");

0 commit comments

Comments
 (0)