UUIDSerde implements Serde<UUID> { public UUID fromBytes(byte[] bytes) { if (bytes != null) { ByteBuffer buffer = ByteBuffer.wrap(bytes); return new UUID(buffer.getLong(), buffer.getLong()); } else { return null; } }  byte[] toBytes(UUID obj); UUID fromBytes(byte[] bytes);  }
@Test public void testFromBytesWhenNull() { assertNull(serde.fromBytes(null)); }
@Test(expected = BufferUnderflowException.class) public void testFromBytesWhenInvalid() { serde.fromBytes(new byte[]{0}); }