Package com.google.speedtracer.breaky.client.JsonSchema

Examples of com.google.speedtracer.breaky.client.JsonSchema.JsonSchemaResults


    if (concreteSchema == null) {
      return JsonSchemaResults.create("", "No schema found for "
          + obj.toString());
    }

    JsonSchemaResults results = JsonSchemaValidator.validate(obj, concreteSchema);
    if (!results.isValid()) {
      return results;
    }

    if (DataBag.hasOwnProperty(obj, "children")) {
      JsArray<JavaScriptObject> children = DataBag.getJSObjectProperty(obj,
          "children");
      for (int i = 0; i < children.length() && results.isValid(); i++) {
        // TODO(conroy): make child validation incremental?
        results = this.validate(children.get(i));
      }
    }
    return results;
View Full Code Here


   * @return
   */
  private String validateRecord(String rawRecord) {
    try {
      JavaScriptObject record = JSON.parse(rawRecord);
      JsonSchemaResults results = validator.validate(record.cast());
      if (results.isValid()) {
        return null;
      } else {
        return formatResults(rawRecord, results);
      }
    } catch (JSONParseException e) {
View Full Code Here

   * On a message, validate.
   * If invalid, report to the host
   */
  public void onMessage(MessageEvent event) {  
    JavaScriptObject record = JSON.parse(event.getDataAsString());
    JsonSchemaResults results = validator.validate(record);
    if (!results.isValid()) {
      postMessage(JSON.stringify(createMessage(record, results.formatResultsText(event.getDataAsString()))));
    }
  }
View Full Code Here

    return sb.toString();
  }

  private static void validateEventRecordFormat(EventRecord event) {
    try {
      JsonSchemaResults results = validator.validate(event);
      if(!results.isValid()) {
        GWTTestCase.fail("Could not validate: \n" + JSON.stringify(event) + "\n"
              + results.getErrors().get(0).getProperty() + " "
              + results.getErrors().get(0).getMessage());
      }
    } catch (JSONParseException e) {
      GWTTestCase.fail("Got an exception trying to JSON parse the record: " + e.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.speedtracer.breaky.client.JsonSchema.JsonSchemaResults

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.