MySQLDatetime2BinlogProtocolValue implements MySQLBinlogProtocolValue { @Override public Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload) { long datetime = readDatetimeV2FromPayload(payload); return 0 == datetime ? MySQLTimeValueUtil.DATETIME_OF_ZERO : readDatetime(columnDef, datetime, payload); }  @Override Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload);  }
@Test public void assertReadWithoutFraction() { when(payload.readInt1()).thenReturn(0xfe, 0xf3, 0xff, 0x7e, 0xfb); assertThat(new MySQLDatetime2BinlogProtocolValue().read(columnDef, payload), is("9999-12-31 23:59:59")); }
@Test public void assertReadWithoutFraction1() { columnDef.setColumnMeta(1); when(payload.readInt1()).thenReturn(0xfe, 0xf3, 0xff, 0x7e, 0xfb, 0x00); assertThat(new MySQLDatetime2BinlogProtocolValue().read(columnDef, payload), is("9999-12-31 23:59:59.0")); }
@Test public void assertReadWithoutFraction3() { columnDef.setColumnMeta(3); when(payload.readInt1()).thenReturn(0xfe, 0xf3, 0xff, 0x7e, 0xfb); when(payload.getByteBuf()).thenReturn(byteBuf); when(byteBuf.readUnsignedShort()).thenReturn(9990); assertThat(new MySQLDatetime2BinlogProtocolValue().read(columnDef, payload), is("9999-12-31 23:59:59.999")); }
@Test public void assertReadWithoutFraction5() { columnDef.setColumnMeta(5); when(payload.readInt1()).thenReturn(0xfe, 0xf3, 0xff, 0x7e, 0xfb); when(payload.getByteBuf()).thenReturn(byteBuf); when(byteBuf.readUnsignedMedium()).thenReturn(999990); assertThat(new MySQLDatetime2BinlogProtocolValue().read(columnDef, payload), is("9999-12-31 23:59:59.99999")); }
@Test public void assertReadNullTime() { assertThat(new MySQLDatetime2BinlogProtocolValue().read(columnDef, payload), is(MySQLTimeValueUtil.DATETIME_OF_ZERO)); }