Skip to content

Commit

Permalink
Added test for epochMilli
Browse files Browse the repository at this point in the history
  • Loading branch information
kpartlow committed Jan 29, 2024
1 parent ddb52cd commit e96ba1d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/java/com/cedarsoftware/util/convert/ConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -692,6 +693,18 @@ void testToBoolean_falseCases(Object input) {
}


private static Stream<Arguments> epochMilliWithZoneId() {
return Stream.of(
Arguments.of("946702799959", TOKYO),
Arguments.of("946702799959", PARIS),
Arguments.of("946702799959", GMT),
Arguments.of("946702799959", NEW_YORK),
Arguments.of("946702799959", CHICAGO),
Arguments.of("946702799959", LOS_ANGELES)
);
}


private static Stream<Arguments> dateStringNoZoneOffset() {
return Stream.of(
Arguments.of("2000-01-01T13:59:59", TOKYO),
Expand Down Expand Up @@ -737,6 +750,21 @@ private static Stream<Arguments> dateStringInIsoZoneDateTime() {
);
}

@ParameterizedTest
@MethodSource("epochMilliWithZoneId")
void testEpochMilliWithZoneId(String epochMilli, ZoneId zoneId) {
LocalDateTime localDateTime = this.converter.convert(epochMilli, LocalDateTime.class, createCustomZones(zoneId, NEW_YORK));

assertThat(localDateTime)
.hasYear(1999)
.hasMonthValue(12)
.hasDayOfMonth(31)
.hasHour(23)
.hasMinute(59)
.hasSecond(59);
}



@ParameterizedTest
@MethodSource("dateStringNoZoneOffset")
Expand Down

0 comments on commit e96ba1d

Please sign in to comment.