@Test
  public void testMissingDataChunkException() throws Exception {
    // Make sure we have two data chunks
    blobSize = maxChunkSize + maxChunkSize / 2;
    doPut();

    // Now remove the all the data chunks, first collect data chunk ids and remove blob id
    Set<String> dataChunkIds = new HashSet<>();
    mockServerLayout.getMockServers().forEach(server -> dataChunkIds.addAll(server.getBlobs().keySet()));
    dataChunkIds.remove(blobIdStr);
    Assert.assertEquals(2, dataChunkIds.size());
    // We can't just delete the data chunks by calling router.deleteBlob, we have to remove them from the mock servers.
    mockServerLayout.getMockServers()
        .forEach(server -> dataChunkIds.forEach(chunkId -> server.getBlobs().remove(chunkId)));
    GetBlobResult result = router.getBlob(blobIdStr, new GetBlobOptionsBuilder().build()).get();
    Future<Long> future = result.getBlobDataChannel().readInto(new ByteBufferAsyncWritableChannel(), null);
    try {
      future.get();
      Assert.fail("Should fail with exception");
    } catch (Exception e) {
      Throwable cause = e.getCause();
      Assert.assertTrue(cause instanceof RestServiceException);
      Assert.assertEquals(RestServiceErrorCode.InternalServerError, ((RestServiceException) cause).getErrorCode());
      Assert.assertTrue(((RestServiceException) cause).shouldIncludeExceptionMessageInResponse());
    }
  }
Test when data chunks are missing, the getBlob should return RestServiceException.
@throws Exception
ambry-router/src/test/java/com/github/ambry/router/GetBlobOperationTest.java