@Test
  public void setRequestCostHeaderTest() {
    Map<String, Double> costMap = new HashMap<>();

    // test for valid cost map
    costMap.put(QuotaName.READ_CAPACITY_UNIT.name(), 1.9);
    costMap.put(QuotaName.STORAGE_IN_GB.name(), 3.0);
    String expectedQuotaHeaderValue = "READ_CAPACITY_UNIT=1.9; STORAGE_IN_GB=3.0";
    MockRestResponseChannel responseChannel = new MockRestResponseChannel();
    RestUtils.setRequestCostHeader(costMap, responseChannel);
    Map<String, Object> responseHeaders = responseChannel.getResponseHeaders();
    assertEquals("Expected one header", 1, responseHeaders.size());
    assertEquals("Unexpected quota header value", expectedQuotaHeaderValue,
        responseHeaders.get(RestUtils.RequestCostHeaders.REQUEST_COST));

    // test for null cost map
    try {
      RestUtils.setRequestCostHeader(null, responseChannel);
      fail("Null costMap should throw error");
    } catch (NullPointerException npEx) {
      assertEquals("Expected one header", 1, responseHeaders.size());
    }

    // test for empty cost map
    costMap = new HashMap<>();
    RestUtils.setRequestCostHeader(costMap, responseChannel);
    responseHeaders = responseChannel.getResponseHeaders();
    assertEquals("Expected one header", 1, responseHeaders.size());
    assertEquals("Unexpected quota header value", "", responseHeaders.get(RestUtils.RequestCostHeaders.REQUEST_COST));
  }
Tests for {@link RestUtils#setRequestCostHeader} method.
ambry-api/src/test/java/com/github/ambry/rest/RestUtilsTest.java