@Test
public void testDeleteResultMetadata() throws Exception {

  Result result = new ResultImpl(true);
  result.setResultStatus(new ResultStatus(ResultStatus.STATUS.OK));
  DeleteResultMetadata metadata = new DeleteResultMetadata();
  metadata.addDeletedKey("key1");
  metadata.addException("key2", new AuthorizationException());
  result.setResultMetadata(metadata);
  String expected =
      "{\n" +
      "  \"deleteResult\" : [\n"+
      "    {\n" +
      "      \"deleted\" : {\n" +
      "        \"key\" : \"key1\"\n" +
      "      }\n" +
      "    },\n" +
      "    {\n" +
      "      \"error\" : {\n" +
      "        \"key\" : \"key2\",\n" +
      "        \"code\" : 403,\n" +
      "        \"message\" : \"org.apache.ambari.server.security.authorization.AuthorizationException:"+
                            " The authenticated user is not authorized to perform the requested operation\"\n" +
      "      }\n" +
      "    }\n" +
      "  ]\n" +
      "}";
  String  json = new JsonSerializer().serialize(result).toString().replace("\r", "");
  assertEquals(expected, json);
}