private void doSerDeTest(StoreFindToken token, Short... versions) throws IOException {
    for (Short version : versions) {
      DataInputStream stream = getSerializedStream(token, version);
      StoreFindToken deSerToken = StoreFindToken.fromBytes(stream, STORE_KEY_FACTORY);
      assertEquals("Stream should have ended ", 0, stream.available());
      assertEquals("Version mismatch for token ", version.shortValue(), deSerToken.getVersion());
      compareTokens(token, deSerToken);
      assertEquals("SessionId does not match", token.getSessionId(), deSerToken.getSessionId());
      if (version >= VERSION_2) {
        assertEquals("IncarnationId mismatch ", token.getIncarnationId(), deSerToken.getIncarnationId());
      }
      if (version == VERSION_3) {
        assertEquals("Reset key mismatch ", token.getResetKey(), deSerToken.getResetKey());
        assertEquals("Reset key type mismatch", token.getResetKeyType(), deSerToken.getResetKeyType());
        assertEquals("Reset key life version mismatch", token.getResetKeyVersion(), deSerToken.getResetKeyVersion());
      }
      // use StoreFindToken's actual serialize method to verify that token is serialized in the expected
      // version
      stream = new DataInputStream(new ByteBufferInputStream(ByteBuffer.wrap(deSerToken.toBytes())));
      deSerToken = StoreFindToken.fromBytes(stream, STORE_KEY_FACTORY);
      assertEquals("Stream should have ended ", 0, stream.available());
      assertEquals("Version mismatch for token ", version.shortValue(), deSerToken.getVersion());
      compareTokens(token, deSerToken);
      assertEquals("SessionId does not match", token.getSessionId(), deSerToken.getSessionId());
      if (version >= VERSION_2) {
        assertEquals("IncarnationId mismatch ", token.getIncarnationId(), deSerToken.getIncarnationId());
      }
    }
  }
Serializes {@code token} in all formats and ensures that the {@link StoreFindToken} obtained from the
deserialization matches the original.
@param token the {@link StoreFindToken} that has to be serialized/deserialized.
@param versions {@link List} of valid versions that the token to be tested for
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/StoreFindTokenTest.java