@Test
  public void buildStateForFileCopyTest() throws Exception {
    int newMountPathIndex = 3;
    int newPartitionId = 803;
    StorageManager storageManager = initializeStorageManagerForStateBuildTests(newMountPathIndex);
    PartitionId newPartition =
        new MockPartitionId(newPartitionId, MockClusterMap.DEFAULT_PARTITION_CLASS, clusterMap.getDataNodes(), newMountPathIndex);
    MockDataNodeId localNode = clusterMap.getDataNodes().get(0);
    // test add store onto a new disk, which should succeed
    assertTrue("Add new store should succeed", storageManager.addBlobStore(newPartition.getReplicaIds().get(0)));
    assertNotNull("The store shouldn't be null because new store is successfully added",
        storageManager.getStore(newPartition, false));
    DiskManager dm = storageManager.getDiskManager(newPartition);
    Store store = dm.getStore(newPartition, false);
    MockId id1 = addRandomBlobToStore(store, 100, Utils.Infinite_Time);
    MockId id2 = addRandomBlobToStore(store, 200, Utils.Infinite_Time);

    // Shutdown store and try to build state using buildStateForFileCopy assuming state has to be built for the same
    // store with 2 blobs present on the partition's file on disk.
    store.shutdown();
    storageManager.buildStateForFileCopy(newPartition.getReplicaIds().get(0));
    dm = storageManager.getDiskManager(newPartition);
    store = dm.getStore(newPartition, false);
    assertNotNull(store.get(Collections.singletonList(id1), EnumSet.noneOf(StoreGetOptions.class)));
    assertNotNull(store.get(Collections.singletonList(id2), EnumSet.noneOf(StoreGetOptions.class)));
  }
Test buildStateForFileCopy with newly created {@link ReplicaId}.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java