@Test
  public void buildStateForFileCopyDuplicateBlobStoreFailureTest() throws Exception {
    int newMountPathIndex = 3;
    int newPartitionId = 803;
    StorageManager storageManager = initializeStorageManagerForStateBuildTests(newMountPathIndex);

    PartitionId newPartition =
        new MockPartitionId(newPartitionId, MockClusterMap.DEFAULT_PARTITION_CLASS, clusterMap.getDataNodes(), newMountPathIndex);

    // 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));
    // Attempting to add store via addBlobStoreForFileCopy should fail since the newPartition already has store started.
    assertFalse("Add store which is already existing should fail", storageManager.addBlobStoreForFileCopy(newPartition.getReplicaIds().get(0)));
    storageManager.getStore(newPartition, false).shutdown();

    // Testing flow where addBlobStoreForFileCopy is called before addBlobStore
    // test add store onto a new disk, which should succeed
    assertTrue("Add store using addBlobStoreForFileCopy should succeed", storageManager.addBlobStoreForFileCopy(newPartition.getReplicaIds().get(0)));
    assertNotNull("The store shouldn't be null because new store is successfully added",
        storageManager.getStore(newPartition, false));
    // This should fail since the newPartition already has store started.
    assertFalse("Add the duplicate store using addBlobStore should fail", storageManager.addBlobStore(newPartition.getReplicaIds().get(0)));
    storageManager.getStore(newPartition, false).shutdown();
  }
Test buildStateForFileCopy with newly created {@link ReplicaId} for failure to add an already started blob store.
@throws Exception
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java