@Test
  public void getClusterMapSnapshotTest() throws Exception {
    RestRequest restRequest = createRestRequest(RestMethod.GET, Operations.GET_CLUSTER_MAP_SNAPSHOT, null, null);
    MockRestResponseChannel restResponseChannel = new MockRestResponseChannel();
    doOperation(restRequest, restResponseChannel);
    JSONObject expected = clusterMap.getSnapshot();
    JSONObject actual = new JSONObject(new String(restResponseChannel.getResponseBody()));
    // remove timestamps because they may differ
    expected.remove(ClusterMapSnapshotConstants.TIMESTAMP_MS);
    actual.remove(ClusterMapSnapshotConstants.TIMESTAMP_MS);
    assertEquals("Snapshot does not match expected", expected.toString(), actual.toString());

    // test a failure to ensure that it goes through the exception path
    String msg = TestUtils.getRandomString(10);
    clusterMap.setExceptionOnSnapshot(new RuntimeException(msg));
    restRequest = createRestRequest(RestMethod.GET, Operations.GET_CLUSTER_MAP_SNAPSHOT, null, null);
    try {
      doOperation(restRequest, new MockRestResponseChannel());
      fail("Operation should have failed");
    } catch (RuntimeException e) {
      assertEquals("Exception not as expected", msg, e.getMessage());
    }
    clusterMap.setExceptionOnSnapshot(null);
  }
Tests the handling of {@link Operations#GET_CLUSTER_MAP_SNAPSHOT} requests.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java