@Test
  public void offsetSerDeTest() throws IOException {
    long pos = Utils.getRandomLong(TestUtils.RANDOM, 1000);
    long gen = Utils.getRandomLong(TestUtils.RANDOM, 1000);
    LogSegmentName name = LogSegmentName.fromPositionAndGeneration(pos, gen);
    long offset = Utils.getRandomLong(new Random(), Long.MAX_VALUE);
    Offset logOffset = new Offset(name, offset);
    byte[] serialized = logOffset.toBytes();
    Offset deserializedOffset =
        Offset.fromBytes(new DataInputStream(new ByteBufferInputStream(ByteBuffer.wrap(serialized))));
    assertEquals("Original offset 'name' does not match with the deserialized offset", name,
        deserializedOffset.getName());
    assertEquals("Original offset 'offset' does not match with the deserialized offset", offset,
        deserializedOffset.getOffset());
    // equals test
    assertEquals("Original offset does not match with the deserialized offset", logOffset, deserializedOffset);
    // hashcode test
    assertEquals("Hashcode doesn't match", logOffset.hashCode(), deserializedOffset.hashCode());
  }
Tests serialization and deserialization of an {@link Offset} class.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/OffsetTest.java