Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-8023 Test failure after NIFI-7996 commit if system default TZ is… #4677

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -683,7 +683,7 @@ public void testConvertToAvroStreamForDateTimeAsLogicalType() throws SQLExceptio
final long millisSinceEpoch = TimeUnit.MILLISECONDS.convert(daysSinceEpoch, TimeUnit.DAYS);
java.sql.Date actual = java.sql.Date.valueOf(Instant.ofEpochMilli(millisSinceEpoch).atZone(ZoneOffset.UTC).toLocalDate());
LOGGER.debug("comparing dates, expecting '{}', actual '{}'", date, actual);
assertEquals(date, actual);
assertEquals(date.toLocalDate(), actual.toLocalDate());
},
(record, time) -> {
int millisSinceMidnight = (int) record.get("time");
Expand Down Expand Up @@ -739,7 +739,7 @@ private void testConvertToAvroStreamForDateTime(
when(metadata.getColumnType(1)).thenReturn(Types.DATE);
when(metadata.getColumnName(1)).thenReturn("date");
ZonedDateTime parsedDate = toZonedDateTime.apply("yyyy/MM/dd", "2017/05/10");
final java.sql.Date date = java.sql.Date.valueOf(parsedDate.toLocalDate());
final java.sql.Date date = new java.sql.Date(parsedDate.toInstant().toEpochMilli());
when(rs.getObject(1)).thenReturn(date);

when(metadata.getColumnType(2)).thenReturn(Types.TIME);
Expand Down
Expand Up @@ -56,6 +56,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.TimeZone;
import java.util.UUID;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -483,7 +484,7 @@ public void testBytesDecimalConversion(){

@Test
public void testDateConversion() {
final Calendar c = Calendar.getInstance();
final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2019, Calendar.JANUARY, 1, 0, 0, 0);
final long epochMillis = c.getTimeInMillis();

Expand All @@ -492,7 +493,7 @@ public void testDateConversion() {
dateType.addToSchema(fieldSchema);
final Object convertedValue = AvroTypeUtil.convertToAvroObject(new Date(epochMillis), fieldSchema);
assertTrue(convertedValue instanceof Integer);
assertEquals((int) convertedValue, LocalDate.of(2019, 1, 1).toEpochDay());
assertEquals(LocalDate.of(2019, 1, 1).toEpochDay(), (int) convertedValue);
}

@Test
Expand Down