@Test
  public void isPrivateTest() throws Exception {
    String serviceId = generateRandomString(10);
    String contentType = "image/gif";
    JSONObject headers = new JSONObject();
    // using this just to help with setting the other necessary headers - doesn't matter what the container is, the
    // PRIVATE header won't have been set.
    setAmbryHeadersForPut(headers, null, serviceId, Container.DEFAULT_PRIVATE_CONTAINER, contentType, null);

    // isPrivate not true or false.
    headers.put(RestUtils.Headers.PRIVATE, "!(true || false)");
    RestRequest restRequest = createRestRequest(RestMethod.POST, "/", headers);
    try {
      RestUtils.isPrivate(restRequest.getArgs());
      fail("An exception was expected but none were thrown");
    } catch (RestServiceException e) {
      assertEquals("Unexpected RestServiceErrorCode", RestServiceErrorCode.InvalidArgs, e.getErrorCode());
    }

    // isPrivate null.
    headers.put(RestUtils.Headers.PRIVATE, JSONObject.NULL);
    restRequest = createRestRequest(RestMethod.POST, "/", headers);
    assertFalse("isPrivate should be false because it was not set", RestUtils.isPrivate(restRequest.getArgs()));

    // isPrivate false
    headers.put(RestUtils.Headers.PRIVATE, "false");
    restRequest = createRestRequest(RestMethod.POST, "/", headers);
    assertFalse("isPrivate should be false because it was set to false", RestUtils.isPrivate(restRequest.getArgs()));

    // isPrivate true
    headers.put(RestUtils.Headers.PRIVATE, "true");
    restRequest = createRestRequest(RestMethod.POST, "/", headers);
    assertTrue("isPrivate should be true because it was set to true", RestUtils.isPrivate(restRequest.getArgs()));
  }
Tests for {@link RestUtils#isPrivate(Map)}
@throws Exception
ambry-api/src/test/java/com/github/ambry/rest/RestUtilsTest.java