Skip to content

Commit 3b3bd49

Browse files
committed
refactor: use assertThat().isToday() and .isInSameDayAs() to simplify code.
This change is needed in order to simplify automated porting of tests. Part of 1246
1 parent 4079d28 commit 3b3bd49

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/test/groovy/ru/mystamps/web/feature/site/LegacyCronServiceImplTest.groovy

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package ru.mystamps.web.feature.site
1919

20+
import static org.assertj.core.util.DateUtil.yesterday
21+
2022
import org.assertj.core.api.WithAssertions
2123
import org.slf4j.helpers.NOPLogger
2224
import ru.mystamps.web.feature.account.UserService
@@ -62,21 +64,15 @@ class LegacyCronServiceImplTest extends Specification implements WithAssertions
6264
.hasMillisecond(0)
6365
}
6466

65-
private static void assertDatesEqual(Date first, Date second) {
66-
assert first[Calendar.YEAR] == second[Calendar.YEAR]
67-
assert first[Calendar.MONTH] == second[Calendar.MONTH]
68-
assert first[Calendar.DAY_OF_MONTH] == second[Calendar.DAY_OF_MONTH]
69-
}
70-
7167
private void assertMidnightOfYesterday(Date date) {
7268
assertThat(date).isNotNull()
73-
assertDatesEqual(date, new Date().previous())
69+
assertThat(date).isInSameDayAs(yesterday())
7470
assertMidnight(date)
7571
}
7672

7773
private void assertMidnightOfToday(Date date) {
7874
assertThat(date).isNotNull()
79-
assertDatesEqual(date, new Date())
75+
assertThat(date).isToday()
8076
assertMidnight(date)
8177
}
8278

0 commit comments

Comments
 (0)