Package org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton

Examples of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector


    System.out.println(doc);

    DocOp docOp = doc.consumeAndReturnInvertible(op);

    System.out.println(op + "==========> " + docOp);
    ViolationCollector v = new ViolationCollector();
    if (!DocOpValidator.validate(v, DocumentSchema.NO_SCHEMA_CONSTRAINTS,
        Automatons.fromReadable(copy), docOp).isValid()) {
      v.printDescriptions(System.err);
      fail("Invalid operation");
    }

    copy.consume(docOp);

    System.out.println("=======" + doc + " --------- " + copy);
    assertEquals(
        DocOpUtil.toXmlString(doc.asOperation()),
        DocOpUtil.toXmlString(copy.asOperation()));
    DocOp inverted = DocOpInverter.invert(docOp);
    v = new ViolationCollector();
    if (!DocOpValidator.validate(v, DocumentSchema.NO_SCHEMA_CONSTRAINTS,
        Automatons.fromReadable(copy), inverted).isValid()) {
      v.printDescriptions(System.err);
      fail("Invalid operation");
    }
    copy.consume(inverted);
    assertEquals(initial, DocOpUtil.toXmlString(copy.asOperation()));
  }
View Full Code Here


    // initialize document
    doc.consume(d.finishUnchecked());

    // check whether m would apply
    ViolationCollector v = new ViolationCollector();
    ValidationResult result =
        DocOpValidator.validate(v, t.getSchemaConstraints(), doc, m.finishUnchecked());

    try {
      assertEquals(expected, v.isValid());
      assertEquals(result, v.getValidationResult());
    } catch (AssertionFailedError e) {
      System.err.println("test data:");
      System.err.println(DocOpUtil.toConciseString(d.finish()));
      System.err.println(DocOpUtil.toConciseString(m.finish()));
      System.err.println("violations:");
      v.printDescriptions(System.err);
      throw e;
    }
  }
View Full Code Here

//      }
    }
  }

  private void validate(AutomatonDocument doc, DocOp op) {
    ViolationCollector v = new ViolationCollector();
    if (!DocOpValidator.validate(v, null, doc, op).isValid()) {
      v.printDescriptions(System.err);
      throw new AssertionFailedError("Validation failed: " + v);
    }
  }
View Full Code Here

  }

  public void maybeThrowOperationExceptionFor(DocOp op) throws OperationException {
    if (!DocOpValidator.validate(null, schemaConstraints, autoDoc, op).isValid()) {
      // Validate again to collect diagnostics (more expensive)
      ViolationCollector vc = new ViolationCollector();
      DocOpValidator.validate(vc, schemaConstraints, autoDoc, op);

      throw new OperationException(vc);
    }
  }
View Full Code Here

    return nindoCursor.finish2();
  }

  @Override
  public void maybeThrowOperationExceptionFor(Nindo op) throws OperationException {
    ViolationCollector vc = NindoValidator.validate(this, op, schemaConstraints);
    if (!vc.isValid()) {
      // TODO(danilatos): reconcile the two validation methods
      throw new OperationException(vc);
    }
  }
View Full Code Here

                .initializationEnd(toArray(keysToEnd))
                .updateValues(toArray(changeKeys), toArray(changeOldValues),
                    toArray(changeNewValues)).build();
            final RandomizerOperationComponent component = generate(map);
            DocOpAutomaton temp = new DocOpAutomaton(a);
            ViolationCollector v = new ViolationCollector();
            component.check(temp, v);
            assert !component.check(temp, null).isIllFormed();
            component.apply(temp);
//            System.err.println("begin lookahead for " + map);
            RandomizerOperationComponent followup = pickComponent(temp, stage);
View Full Code Here

   * Returns a randomly-generated document operation based on the given document,
   * parameters, and schema.
   */
  public static DocOp generate(RandomProvider r, Parameters p, AutomatonDocument doc) {
    DocOp op = new Generator(r, p, doc).generate();
    ViolationCollector v = new ViolationCollector();
    DocOpValidator.validate(v, null, doc, op);
    assert !v.isIllFormed();
    assert p.getValidity() == v.isValid();
    return op;
  }
View Full Code Here

   * @throws IllegalStateException if the op is ill-formed
   */
  private static void checkWellformedness(DocOp value) {
    if (!DocOpValidator.isWellFormed(null, value)) {
      // Check again, collecting violations this time.
      ViolationCollector v = new ViolationCollector();
      DocOpValidator.isWellFormed(v, value);
      Preconditions.illegalState("Attempt to build ill-formed operation (" + v + "): " + value);
    }
  }
View Full Code Here

      IndexedDocument<N, E, T> doc,
      Nindo m, DocumentSchema schema) {
    Preconditions.checkNotNull(schema, "Schema constraints required, if not, " +
        "use DocumentSchema.NO_SCHEMA_CONSTRAINTS");
    final NindoAutomaton<N, E, T> a = new NindoAutomaton<N, E, T>(schema, doc);
    final ViolationCollector v = new ViolationCollector();
    try {
      m.apply(new NindoCursor() {

        @Override
        public void begin() {
View Full Code Here

   * parameters, and schema.
   */
  public static Nindo generate(RandomProvider r, Parameters p,
      DocumentSchema s, IndexedDocument<Node, Element, Text> doc) {
    Nindo m = new Generator(r, p, s, doc).generate();
    ViolationCollector v = NindoValidator.validate(doc, m, s);
    assert !v.isIllFormed();
    assert p.getValidity() == v.isValid();
    return m;
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector

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.