@Test
  public void getAccountsTest() throws Exception {
    RestRequest restRequest = createRestRequest(RestMethod.GET, Operations.ACCOUNTS, null, null);
    MockRestResponseChannel restResponseChannel = new MockRestResponseChannel();
    doOperation(restRequest, restResponseChannel);
    Set<Account> expected = new HashSet<>(accountService.getAllAccounts());
    Set<Account> actual = new HashSet<>(AccountCollectionSerde.accountsFromInputStreamInJson(
        new ByteArrayInputStream(restResponseChannel.getResponseBody())));
    assertEquals("Unexpected GET /accounts response", expected, actual);

    // test an account not found case to ensure that it goes through the exception path
    restRequest = createRestRequest(RestMethod.GET, Operations.ACCOUNTS,
        new JSONObject().put(RestUtils.Headers.TARGET_ACCOUNT_ID, accountService.generateRandomAccount().getId()),
        null);
    try {
      doOperation(restRequest, new MockRestResponseChannel());
      fail("Operation should have failed");
    } catch (RestServiceException e) {
      assertEquals("Error code not as expected", RestServiceErrorCode.NotFound, e.getErrorCode());
    }
  }
Tests the handling of {@link Operations#ACCOUNTS} get requests.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java