@Test
  public void decodeKVHeaderValueTest() {
    // test for empty string
    assertTrue("Invalid encoded value", RestUtils.KVHeaderValueEncoderDecoder.decodeKVHeaderValue("").isEmpty());

    // test for null string
    try {
      RestUtils.KVHeaderValueEncoderDecoder.decodeKVHeaderValue(null);
      fail("Null value should throw error");
    } catch (NullPointerException npEx) {
    }

    // test for valid string
    String validEncodedHeader = "READ_CAPACITY_UNIT=1.9; STORAGE_IN_GB=3.0; ";
    Map<String, String> decodedMap = new HashMap<>();
    decodedMap.put("READ_CAPACITY_UNIT", "1.9");
    decodedMap.put("STORAGE_IN_GB", "3.0");
    assertEquals("Invalid encoded value", RestUtils.KVHeaderValueEncoderDecoder.decodeKVHeaderValue(validEncodedHeader),
        decodedMap);

    // test for single value
    validEncodedHeader = "READ_CAPACITY_UNIT=1.9";
    decodedMap = new HashMap<>();
    decodedMap.put("READ_CAPACITY_UNIT", "1.9");
    assertEquals("Invalid encoded value", RestUtils.KVHeaderValueEncoderDecoder.decodeKVHeaderValue(validEncodedHeader),
        decodedMap);

    // test for invalid strings.
    String[] invalidEncodedHeaders = new String[]{"invalid", "; ", "bad; bad; ", ";", "="};
    for (String invalidEncodedHeader : invalidEncodedHeaders) {
      try {
        RestUtils.KVHeaderValueEncoderDecoder.decodeKVHeaderValue(invalidEncodedHeader);
        fail("Decode of invalid encoded header " + invalidEncodedHeader + " should fail.");
      } catch (IllegalArgumentException iaEx) {
      }
    }
  }
Tests for {@link RestUtils.KVHeaderValueEncoderDecoder#decodeKVHeaderValue(String)}.
ambry-api/src/test/java/com/github/ambry/rest/RestUtilsTest.java