private void removeDisabledReplicasIfNeeded(InstanceConfig instanceConfig) {
    if (instanceConfig == null) {
      return;
    }
    Map<String, List<String>> disabledReplicasByResource = instanceConfig.getDisabledPartitionsMap();
    if (!disabledReplicasByResource.isEmpty()) {
      // if disabled replica map is not empty, we remove those replicas from InstanceConfig to mock replica decommission
      Set<String> replicasToRemove = new HashSet<>();
      disabledReplicasByResource.values().forEach(replicasToRemove::addAll);
      Map<String, Map<String, String>> newMapFields = new HashMap<>();
      Map<String, Map<String, String>> mapFields = instanceConfig.getRecord().getMapFields();
      for (Map.Entry<String, Map<String, String>> entry : mapFields.entrySet()) {
        if (entry.getKey().startsWith("/mnt")) {
          String replicasStr = entry.getValue().get(REPLICAS_STR);
          if (!replicasStr.isEmpty()) {
            String[] replicaArray = replicasStr.split(REPLICAS_DELIM_STR);
            StringBuilder sb = new StringBuilder();
            for (String replicaStr : replicaArray) {
              if (!replicasToRemove.contains(replicaStr.split(REPLICAS_STR_SEPARATOR)[0])) {
                sb.append(replicaStr).append(REPLICAS_DELIM_STR);
              }
            }
            entry.getValue().put(REPLICAS_STR, sb.toString());
          }
          newMapFields.put(entry.getKey(), entry.getValue());
        }
      }
      instanceConfig.getRecord().setMapFields(newMapFields);
    }
  }
Remove disabled replicas from InstanceConfig if needed. This is to mock last step of disabling replica, which will
remove the replica entry from InstanceConfig.
@param instanceConfig the instanceConfig to check.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/MockHelixAdmin.java