Expand current day on startup (#129)

This commit is contained in:
Mikołaj Pich
2018-05-31 23:54:59 +02:00
committed by Rafał Borcz
parent 228f680e5d
commit e2003e2538
6 changed files with 74 additions and 9 deletions

View File

@ -2,6 +2,7 @@ package io.github.wulkanowy.utils;
import org.junit.Assert;
import org.junit.Test;
import org.threeten.bp.LocalDate;
import java.text.DateFormat;
import java.text.ParseException;
@ -47,6 +48,11 @@ public class TimeUtilsTest {
Assert.assertEquals(636080256000000000L, TimeUtils.getNetTicks("2016-08-29"));
}
@Test
public void getParsedDateTest() {
Assert.assertEquals(LocalDate.of(1970, 1, 1), TimeUtils.getParsedDate("1970-01-01", "yyyy-MM-dd"));
}
@Test
public void getDateTest() throws Exception {
DateFormat format = new SimpleDateFormat("dd.MM.yyyy", Locale.ROOT);
@ -55,4 +61,38 @@ public class TimeUtilsTest {
Assert.assertEquals(date, TimeUtils.getDate(636370560000000000L));
}
@Test
public void isDateInWeekInsideTest() {
Assert.assertTrue(TimeUtils.isDateInWeek(
LocalDate.of(2018, 5, 28),
LocalDate.of(2018, 5, 31)
));
}
@Test
public void isDateInWeekExtremesTest() {
Assert.assertTrue(TimeUtils.isDateInWeek(
LocalDate.of(2018, 5, 28),
LocalDate.of(2018, 5, 28)
));
Assert.assertTrue(TimeUtils.isDateInWeek(
LocalDate.of(2018, 5, 28),
LocalDate.of(2018, 6, 1)
));
}
@Test
public void isDateInWeekOutOfTest() {
Assert.assertFalse(TimeUtils.isDateInWeek(
LocalDate.of(2018, 5, 28),
LocalDate.of(2018, 6, 2)
));
Assert.assertFalse(TimeUtils.isDateInWeek(
LocalDate.of(2018, 5, 28),
LocalDate.of(2018, 5, 27)
));
}
}