Skip to content

Commit bee069a

Browse files
committed
Fix pack stream V2 test
To not expect DateTime be converted to epoch second in UTC. It is instead converted to epoch second in local time.
1 parent b9c36ad commit bee069a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

driver/src/test/java/org/neo4j/driver/internal/messaging/PackStreamMessageFormatV2Test.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ public void shouldWriteZonedDateTimeWithOffset() throws Exception
280280
int index = buf.readableBytes() - Integer.BYTES - Byte.BYTES - Short.BYTES - Byte.BYTES - Integer.BYTES - Byte.BYTES;
281281
ByteBuf tailSlice = buf.slice( index, buf.readableBytes() - index );
282282

283-
assertByteBufContains( tailSlice, INT_32, (int) dateTime.toEpochSecond(), INT_16, (short) dateTime.getNano(), INT_32, zoneOffset.getTotalSeconds() );
283+
assertByteBufContains( tailSlice,
284+
INT_32, (int) localEpochSecondOf( dateTime ),
285+
INT_16, (short) dateTime.getNano(),
286+
INT_32, zoneOffset.getTotalSeconds() );
284287
}
285288

286289
@Test
@@ -292,7 +295,7 @@ public void shouldReadZonedDateTimeWithOffset() throws Exception
292295
Object unpacked = packAndUnpackValue( packer ->
293296
{
294297
packer.packStructHeader( 3, (byte) 'F' );
295-
packer.pack( dateTime.toInstant().getEpochSecond() );
298+
packer.pack( localEpochSecondOf( dateTime ) );
296299
packer.pack( dateTime.toInstant().getNano() );
297300
packer.pack( zoneOffset.getTotalSeconds() );
298301
} );
@@ -316,7 +319,7 @@ public void shouldWriteZonedDateTimeWithZoneId() throws Exception
316319
ByteBuf tailSlice = buf.slice( index, buf.readableBytes() - index );
317320

318321
List<Number> expectedBuf = new ArrayList<>( asList(
319-
INT_32, (int) dateTime.toInstant().getEpochSecond(),
322+
INT_32, (int) localEpochSecondOf( dateTime ),
320323
INT_16, (short) dateTime.toInstant().getNano(),
321324
STRING_8, (byte) zoneNameBytes.length ) );
322325

@@ -337,7 +340,7 @@ public void shouldReadZonedDateTimeWithZoneId() throws Exception
337340
Object unpacked = packAndUnpackValue( packer ->
338341
{
339342
packer.packStructHeader( 3, (byte) 'f' );
340-
packer.pack( dateTime.toInstant().getEpochSecond() );
343+
packer.pack( localEpochSecondOf( dateTime ) );
341344
packer.pack( dateTime.toInstant().getNano() );
342345
packer.pack( zoneName );
343346
} );
@@ -425,4 +428,9 @@ private MessageFormat.Writer newWriter( ByteBuf buf )
425428
{
426429
return messageFormat.newWriter( new ByteBufOutput( buf ), true );
427430
}
431+
432+
private static long localEpochSecondOf( ZonedDateTime dateTime )
433+
{
434+
return dateTime.toLocalDateTime().toEpochSecond( UTC );
435+
}
428436
}

0 commit comments

Comments
 (0)