### Question:
ClusterContext { void addPartitionToFaultZone(String faultZoneId, String resourceName, String partition) { if (!_assignmentForFaultZoneMap.computeIfAbsent(faultZoneId, k -> new HashMap<>()) .computeIfAbsent(resourceName, k -> new HashSet<>()) .add(partition)) { throw new HelixException( String.format("Resource %s already has a replica from partition %s in fault zone %s", resourceName, partition, faultZoneId)); } } ClusterContext(Set<AssignableReplica> replicaSet, Set<AssignableNode> nodeSet,
      Map<String, ResourceAssignment> baselineAssignment, Map<String, ResourceAssignment> bestPossibleAssignment); Map<String, ResourceAssignment> getBaselineAssignment(); Map<String, ResourceAssignment> getBestPossibleAssignment(); Map<String, Map<String, Set<String>>> getAssignmentForFaultZoneMap(); int getEstimatedMaxPartitionCount(); int getEstimatedMaxPartitionByResource(String resourceName); int getEstimatedMaxTopStateCount(); float getEstimatedMaxUtilization(); Set<String> getPartitionsForResourceAndFaultZone(String resourceName, String faultZoneId);  }### Answer:
@Test(expectedExceptions = HelixException.class, expectedExceptionsMessageRegExp = "Resource Resource1 already has a replica from partition Partition1 in fault zone testZone") public void testDuplicateAssign() throws IOException { ResourceControllerDataProvider testCache = setupClusterDataCache(); Set<AssignableReplica> assignmentSet = generateReplicas(testCache); ClusterContext context = new ClusterContext(assignmentSet, generateNodes(testCache), new HashMap<>(), new HashMap<>()); context.addPartitionToFaultZone(_testFaultZoneId, _resourceNames.get(0), _partitionNames.get(0)); context .addPartitionToFaultZone(_testFaultZoneId, _resourceNames.get(0), _partitionNames.get(0)); }