MySQLTimeBinlogProtocolValue implements MySQLBinlogProtocolValue { @Override public Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload) { int time = payload.getByteBuf().readUnsignedMediumLE(); if (0 == time) { return MySQLTimeValueUtil.ZERO_OF_TIME; } int minuteSecond = Math.abs(time) % 10000; return String.format("%02d:%02d:%02d", time / 10000, minuteSecond / 100, minuteSecond % 100); }  @Override Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload);  }
@Test public void assertRead() { when(payload.getByteBuf()).thenReturn(byteBuf); when(byteBuf.readUnsignedMediumLE()).thenReturn(16 * 10000 + 59 * 100 + 59); assertThat(new MySQLTimeBinlogProtocolValue().read(columnDef, payload), is("16:59:59")); }
@Test public void assertReadNullTime() { when(payload.getByteBuf()).thenReturn(byteBuf); when(byteBuf.readUnsignedMediumLE()).thenReturn(0); assertThat(new MySQLTimeBinlogProtocolValue().read(columnDef, payload), is(MySQLTimeValueUtil.ZERO_OF_TIME)); }