@Test
  public void undeleteTest() throws Exception {
    Assume.assumeTrue(
        MessageFormatRecord.getCurrentMessageHeaderVersion() >= MessageFormatRecord.Message_Header_Version_V3);
    MockPartitionId id = (MockPartitionId) clusterMap.getWritablePartitionIds(DEFAULT_PARTITION_CLASS).get(0);
    int correlationId = TestUtils.RANDOM.nextInt();
    String clientId = TestUtils.getRandomString(10);
    BlobId blobId = new BlobId(CommonTestUtils.getCurrentBlobIdVersion(), BlobId.BlobIdType.NATIVE,
        ClusterMap.UNKNOWN_DATACENTER_ID, Utils.getRandomShort(TestUtils.RANDOM),
        Utils.getRandomShort(TestUtils.RANDOM), id, false, BlobId.BlobDataType.DATACHUNK);
    long opTimeMs = SystemTime.getInstance().milliseconds();

    // since we already test store key conversion in ttlupdate, we don't test it again in this method.
    // storekey not valid for store
    doUndelete(correlationId++, clientId, blobId, opTimeMs, ServerErrorCode.BlobNotFound);
    // valid now
    validKeysInStore.add(blobId);
    doUndelete(correlationId++, clientId, blobId, opTimeMs, ServerErrorCode.NoError);

    // READ_ONLY is fine too
    changePartitionState(id, true);
    doUndelete(correlationId++, clientId, blobId, opTimeMs, ServerErrorCode.NoError);
    changePartitionState(id, false);

    miscUndeleteFailuresTest();
  }
Tests for success and failure scenarios for UNDELETE
ambry-server/src/test/java/com/github/ambry/server/AmbryServerRequestsTest.java