/**
   * Verify the RP consistency group and its volumes have been properly migrated.
   *
   * @throws Exception
   */
  private void verifyRpConsistencyGroupWithDuplicatesMigration() throws Exception {
    log.info("Verifying duplicate protection sets were cleaned up.");

    List<URI> protSetIds = _dbClient.queryByType(ProtectionSet.class, true);

    List<String> protSetNames = new ArrayList<String>();
    for (URI id : protSetIds) {
      ProtectionSet protSet = _dbClient.queryObject(ProtectionSet.class, id);
      if (protSet == null || protSet.getInactive()) {
        continue;
      }
      if (protSetNames.contains(protSet.getLabel())) {
        // fail duplicate protection set
        Assert.fail("Duplicate protection sets exist after migration " + protSet.getLabel());
      } else {
        protSetNames.add(protSet.getLabel());

        // verify that there are no duplicates or stale volumes on the volume list
        List<String> volumeIds = new ArrayList<String>();
        for (String volId : protSet.getVolumes()) {
          Volume vol = _dbClient.queryObject(Volume.class, URI.create(volId));
          if (vol == null || vol.getInactive()) {
            // fail stale volume on protection set
            Assert.fail(
                String.format(
                    "Stale volume %s exists on protection set %s exist after migration",
                    volId, protSet.getLabel()));
          } else if (volumeIds.contains(volId)) {
            // fail duplicate volume on protection set
            Assert.fail(
                String.format(
                    "Duplicate volume %s exists on protection set %s exist after migration",
                    volId, protSet.getLabel()));
          } else if (vol.getProtectionSet() == null
              || vol.getProtectionSet().getURI() == null
              || !vol.getProtectionSet().getURI().equals(protSet.getId())) {
            // fail volume does not point back to protection set
            Assert.fail(
                String.format(
                    "Volume %s does not point back to protection set %s exist after migration",
                    volId, protSet.getLabel()));
          } else {
            volumeIds.add(volId);
          }
        }
      }
    }

    // make sure there are no dangling protection sets on volumes
    List<URI> volumes = _dbClient.queryByType(Volume.class, true);
    for (URI id : volumes) {
      Volume vol = _dbClient.queryObject(Volume.class, id);
      if (vol.getProtectionSet() != null && vol.getProtectionSet().getURI() != null) {
        ProtectionSet protSet =
            _dbClient.queryObject(ProtectionSet.class, vol.getProtectionSet().getURI());
        if (protSet == null || protSet.getInactive()) {
          // fail dangling protection set
          Assert.fail(
              String.format(
                  "Stale protection set %s on volume %s exists after migration",
                  vol.getProtectionSet().getURI(), id));
        }
      }
    }

    // make sure there are no dangling protection sets on snapshots
    List<URI> snapshots = _dbClient.queryByType(BlockSnapshot.class, true);
    for (URI id : snapshots) {
      BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, id);
      if (snapshot.getProtectionSet() != null) {
        ProtectionSet protSet =
            _dbClient.queryObject(ProtectionSet.class, snapshot.getProtectionSet());
        if (protSet == null || protSet.getInactive()) {
          // fail dangling protection set
          Assert.fail(
              String.format(
                  "Stale protection set %s on snapshot %s exists after migration",
                  snapshot.getProtectionSet(), id));
        }
      }
    }
  }