@Test
  public void testUpdateRecordV1() throws IOException, MessageFormatException {
    // Test update V1 record
    // irrespective of what values are set for acccountId, containerId and updateTimeMs, legacy values will be returned
    // with Update_Format_V1
    short accountId = Utils.getRandomShort(TestUtils.RANDOM);
    short containerId = Utils.getRandomShort(TestUtils.RANDOM);
    long updateTimeMs = SystemTime.getInstance().milliseconds() + TestUtils.RANDOM.nextInt();
    ByteBuffer updateRecord = ByteBuffer.allocate(Update_Format_V1.getRecordSize());
    Update_Format_V1.serialize(updateRecord,
        new UpdateRecord(accountId, containerId, updateTimeMs, new DeleteSubRecord()));
    updateRecord.flip();
    UpdateRecord deserializeUpdateRecord =
        MessageFormatRecord.deserializeUpdateRecord(new ByteBufferInputStream(updateRecord));
    Assert.assertEquals("AccountId mismatch ", UNKNOWN_ACCOUNT_ID, deserializeUpdateRecord.getAccountId());
    Assert.assertEquals("ContainerId mismatch ", UNKNOWN_CONTAINER_ID, deserializeUpdateRecord.getContainerId());
    Assert.assertEquals("DeletionTime mismatch ", Utils.Infinite_Time, deserializeUpdateRecord.getUpdateTimeInMs());
    Assert.assertEquals("Type of update record incorrect", SubRecord.Type.DELETE, deserializeUpdateRecord.getType());
    Assert.assertNotNull("DeleteSubRecord is null", deserializeUpdateRecord.getDeleteSubRecord());

    // corrupt update V1 record
    updateRecord.flip();
    byte toCorrupt = updateRecord.get(10);
    updateRecord.put(10, (byte) (toCorrupt + 1));
    try {
      MessageFormatRecord.deserializeUpdateRecord(new ByteBufferInputStream(updateRecord));
      fail("Deserialization of a corrupt update record V1 should have failed ");
    } catch (MessageFormatException e) {
      Assert.assertEquals(e.getErrorCode(), MessageFormatErrorCodes.DataCorrupt);
    }
  }
Tests UpdateRecord V1 for serialization and deserialization
@throws IOException
@throws MessageFormatException
ambry-messageformat/src/test/java/com/github/ambry/messageformat/MessageFormatRecordTest.java