### Question:
GetReplicasHandler { ReadableStreamChannel getReplicas(String blobId, RestResponseChannel restResponseChannel) throws RestServiceException { logger.trace("Getting replicas of blob ID - {}", blobId); long startTime = System.currentTimeMillis(); ReadableStreamChannel channel = null; try { channel = FrontendUtils.serializeJsonToChannel(getReplicas(blobId)); restResponseChannel.setHeader(RestUtils.Headers.CONTENT_TYPE, RestUtils.JSON_CONTENT_TYPE); restResponseChannel.setHeader(RestUtils.Headers.CONTENT_LENGTH, channel.getSize()); } finally { metrics.getReplicasProcessingTimeInMs.update(System.currentTimeMillis() - startTime); } return channel; } GetReplicasHandler(FrontendMetrics metrics, ClusterMap clusterMap);   }### Answer:
@Test public void getReplicasTest() throws Exception { List<? extends PartitionId> partitionIds = CLUSTER_MAP.getWritablePartitionIds(null); for (PartitionId partitionId : partitionIds) { String originalReplicaStr = partitionId.getReplicaIds().toString().replace(", ", ","); BlobId blobId = new BlobId(CommonTestUtils.getCurrentBlobIdVersion(), BlobId.BlobIdType.NATIVE, ClusterMap.UNKNOWN_DATACENTER_ID, Account.UNKNOWN_ACCOUNT_ID, Container.UNKNOWN_CONTAINER_ID, partitionId, false, BlobId.BlobDataType.DATACHUNK); MockRestResponseChannel restResponseChannel = new MockRestResponseChannel(); ReadableStreamChannel channel = getReplicasHandler.getReplicas(blobId.getID(), restResponseChannel); assertEquals("Unexpected response status", ResponseStatus.Ok, restResponseChannel.getStatus()); assertEquals("Unexpected Content-Type", RestUtils.JSON_CONTENT_TYPE, restResponseChannel.getHeader(RestUtils.Headers.CONTENT_TYPE)); String returnedReplicasStr = RestTestUtils.getJsonizedResponseBody(channel) .get(GetReplicasHandler.REPLICAS_KEY) .toString() .replace("\"", ""); assertEquals("Replica IDs returned for the BlobId do no match with the replicas IDs of partition", originalReplicaStr, returnedReplicasStr); } }
@Test public void getReplicasWithBadInputTest() { try { getReplicasHandler.getReplicas("12345", new MockRestResponseChannel()); fail("Exception should have been thrown because the blobid is invalid"); } catch (RestServiceException e) { assertEquals("Unexpected RestServiceErrorCode", RestServiceErrorCode.NotFound, e.getErrorCode()); } String blobId = "AAEAAQAAAAAAAADFAAAAJDMyYWZiOTJmLTBkNDYtNDQyNS1iYzU0LWEwMWQ1Yzg3OTJkZQ.gif"; try { getReplicasHandler.getReplicas(blobId, new MockRestResponseChannel()); fail("Exception should have been thrown because the blobid is invalid"); } catch (RestServiceException e) { assertEquals("Unexpected RestServiceErrorCode", RestServiceErrorCode.NotFound, e.getErrorCode()); } }