public String toJson() {
    JsonObject details = new JsonObject();
    details.addProperty(FIELD_LEVEL, level.toString());
    JsonArray conditionResults = new JsonArray();
    for (EvaluatedCondition condition : this.conditions) {
      conditionResults.add(toJson(condition));
    }
    details.add("conditions", conditionResults);
    details.addProperty(FIELD_IGNORED_CONDITIONS, ignoredConditions);
    return details.toString();
  }
@Test
  public void verify_json_for_condition_on_leak_metric() {
    String value = "actualValue";
    Condition condition = new Condition(new MetricImpl("1", "new_key1", "name1", Metric.MetricType.STRING), Condition.Operator.GREATER_THAN.getDbValue(), "errorTh");
    ImmutableList<EvaluatedCondition> evaluatedConditions = ImmutableList.of(
      new EvaluatedCondition(condition, Measure.Level.OK, value),
      new EvaluatedCondition(condition, Measure.Level.ERROR, value));
    String actualJson = new QualityGateDetailsData(Measure.Level.OK, evaluatedConditions, false).toJson();

    JsonAssert.assertJson(actualJson).isSimilarTo("{" +
      "\"level\":\"OK\"," +
      "\"conditions\":[" +
      "  {" +
      "    \"metric\":\"new_key1\"," +
      "    \"op\":\"GT\"," +
      "    \"error\":\"errorTh\"," +
      "    \"actual\":\"actualValue\"," +
      "    \"period\":1," +
      "    \"level\":\"OK\"" +
      "  }," +
      "  {" +
      "    \"metric\":\"new_key1\"," +
      "    \"op\":\"GT\"," +
      "    \"error\":\"errorTh\"," +
      "    \"actual\":\"actualValue\"," +
      "    \"period\":1," +
      "    \"level\":\"ERROR\"" +
      "  }" +
      "]" +
      "}");
  }