@Test
  @Ignore("Moved token reload to VcrReplicaThread just before replication")
  public void testRetrieveToken() throws ReplicationException {
    StoreFindToken token;
    long lastOpTime;
    Offset offset = new Offset(new LogSegmentName(3, 14), 36);
    VcrClusterParticipant vcrClusterParticipant = mock(VcrClusterParticipant.class);
    when(vcrClusterParticipant.getCurrentDataNodeId()).thenReturn(dataNodeId);
    NetworkClientFactory networkClientFactory = mock(NetworkClientFactory.class);
    VcrReplicationManager vcrReplicationManager =
          new VcrReplicationManager(verifiableProperties, null, storeKeyFactory, mockClusterMap,
              vcrClusterParticipant, azuriteClient, null, networkClientFactory, null,
              null);

    // No one checks if local and peer are the same replica. Hmm ?
    // test 1: uninitialized token
    lastOpTime = Utils.Infinite_Time;
    token =  new StoreFindToken(FindTokenType.Uninitialized, null, null, null, null,
        true, (short) 3, null, null, (short) -1);
    uploadTokenToAzureTable(replica, token, lastOpTime);
    vcrReplicationManager.reloadReplicationTokenIfExists(
        mockPartitionId.getReplicaIds().get(0), Collections.singletonList(replica));
    assertEquals(token, replica.getToken());

    // test 2: journal-based token w/o reset key
    lastOpTime = Utils.Infinite_Time;
    token = new StoreFindToken(FindTokenType.JournalBased, offset, null, UUID.randomUUID(), UUID.randomUUID(),
        false, (short) 3, null, null, (short) -1);
    uploadTokenToAzureTable(replica, token, lastOpTime);
    vcrReplicationManager.reloadReplicationTokenIfExists(
        mockPartitionId.getReplicaIds().get(0), Collections.singletonList(replica));
    assertEquals(token, replica.getToken());

    // test 3: journal-based token w/ reset key
    lastOpTime = System.currentTimeMillis();
    BlobId resetKey = getUniqueId(ACCOUNT_ID, CONTAINER_ID, false, mockPartitionId);
    token = new StoreFindToken(FindTokenType.JournalBased, offset, null, UUID.randomUUID(), UUID.randomUUID(),
        false, (short) 3, resetKey, PersistentIndex.IndexEntryType.PUT, (short) 3);
    uploadTokenToAzureTable(replica, token, lastOpTime);
    vcrReplicationManager.reloadReplicationTokenIfExists(
        mockPartitionId.getReplicaIds().get(0), Collections.singletonList(replica));
    assertEquals(token, replica.getToken());

    // test 4: index-based token
    lastOpTime = System.currentTimeMillis();
    BlobId storeKey = getUniqueId(ACCOUNT_ID, CONTAINER_ID, false, mockPartitionId);
    token = new StoreFindToken(FindTokenType.IndexBased, offset, storeKey, UUID.randomUUID(), UUID.randomUUID(),
        false, (short) 3, resetKey, PersistentIndex.IndexEntryType.PUT, (short) 3);
    uploadTokenToAzureTable(replica, token, lastOpTime);
    vcrReplicationManager.reloadReplicationTokenIfExists(
        mockPartitionId.getReplicaIds().get(0), Collections.singletonList(replica));
    assertEquals(token, replica.getToken());
  }
Tests that no token is uploaded to Azure Table if the token is unchanged in a repl-cycle.
This save dollars.
ambry-vcr/src/test/java/com/github/ambry/vcr/CloudTokenPersistorTest.java