Package org.waveprotocol.wave.model.document.operation.impl

Examples of org.waveprotocol.wave.model.document.operation.impl.DocOpBuilder


public class TransformerTest extends TestCase {

  public void testClientOpLongerThanServerOp() {
    try {
      Transformer.transform(new DocOpBuilder().retain(1).build(), new DocOpBuilder().build());
      fail();
    } catch (TransformException e) {
      // ok
    }
  }
View Full Code Here


public class DocOpCollectorTest extends TestCase {

  public void testSimpleMonotonicComposition() {
    DocOpCollector collector = new DocOpCollector();

    DocOp a = new DocOpBuilder().characters("a").build();
    DocOp b = new DocOpBuilder().retain(1).characters("b").build();
    DocOp c = new DocOpBuilder().retain(2).characters("c").build();
    DocOp d = new DocOpBuilder().retain(3).characters("d").build();

    collector.add(a);
    collector.add(b);
    collector.add(c);
    collector.add(d);

    DocOp expected = new DocOpBuilder().characters("abcd").build();
    assertTrue(OpComparators.SYNTACTIC_IDENTITY.equal(expected, collector.composeAll()));
  }
View Full Code Here

    }

    private WaveletOperation noOpDocOp(String blipId) {
      WaveletOperationContext context = new WaveletOperationContext(
          clientMock.getParticipantId(), 0L, 1L);
      BlipContentOperation blipOp = new BlipContentOperation(context, (new DocOpBuilder()).build());

      return new WaveletBlipOperation(blipId, blipOp);
    }
View Full Code Here

      int remaining) {
    if (operation instanceof WaveletBlipOperation) {
      WaveletBlipOperation waveOp = (WaveletBlipOperation) operation;
      if (waveOp.getBlipOp() instanceof BlipContentOperation) {
        BlipContentOperation blipOp = (BlipContentOperation) waveOp.getBlipOp();
        DocOpBuilder builder = new DocOpBuilder();
        builder.retain(location).characters(content);
        if (remaining > 0) {
            builder.retain(remaining);
        }
        assertTrue(OpComparators.SYNTACTIC_IDENTITY.equal(builder.build(), blipOp.getContentOp()));
        return;
      }
    }
    fail("Did not get an insertion operation.");
  }
View Full Code Here

        "yyya_2",
        VALID_PARTIAL + "/" + INVALID_PARTIAL + "/c@@a/a@a/aaaaa@aaaaaaaaaaa/"
      });

  public void testScrubs() {
    DocOpBuilder b1 = new DocOpBuilder();
    DocOpBuilder b2 = new DocOpBuilder();

    b1.characters(VALID);
    b2.characters(VALID_SCRUBBED);

    b1.deleteCharacters(VALID);
    b2.deleteCharacters(VALID_SCRUBBED);

    b1.characters(INVALID);
    b2.characters(INVALID_SCRUBBED);

    b1.deleteCharacters(INVALID);
    b2.deleteCharacters(INVALID_SCRUBBED);

    b1.elementStart("abc", ATTRS);
    b2.elementStart("abc", ATTRS_SCRUBBED);

    b1.elementEnd();
    b2.elementEnd();

    b1.deleteElementStart("abc", ATTRS);
    b2.deleteElementStart("abc", ATTRS_SCRUBBED);

    b1.deleteElementEnd();
    b2.deleteElementEnd();

    b1.retain(5);
    b2.retain(5);

    b1.replaceAttributes(ATTRS, ATTRS);
    b2.replaceAttributes(ATTRS_SCRUBBED, ATTRS_SCRUBBED);

    b1.updateAttributes(ATTRSUP);
    b2.updateAttributes(ATTRSUP_SCRUBBED);

    b1.annotationBoundary(ANNO);
    b2.annotationBoundary(ANNO_SCRUBBED);

    DocOp o1 = DocOpScrub.scrub(b1.buildUnchecked());
    DocOp o2 = b2.buildUnchecked();
    assertTrue("\n" + o1 + "\n but expected \n" + o2,
        OpComparators.SYNTACTIC_IDENTITY.equal(o1, o2));
  }
View Full Code Here

   * makes assumptions about what type of deltas are used by
   * {@link OperationQueue} and what operations those deltas merge.
   */
  public void testProducesOptimisedDeltas() {
    queue.add(new WaveletBlipOperation("a", new BlipContentOperation(BOB_A.getContext(),
        new DocOpBuilder().retain(1).characters("hi").retain(1).build())));
    queue.add(new WaveletBlipOperation("a", new BlipContentOperation(BOB_B.getContext(),
        new DocOpBuilder().retain(1).characters("hi").retain(3).build())));
    assertQueueSizeBetween(1, 2);
    assertEquals(1, queue.take().size());
    assertQueueIsEmpty();
  }
View Full Code Here

  private static void compareDocOpList(List<DocOp> ops, DocOp op) {
    assertTrue(OpComparators.SYNTACTIC_IDENTITY.equal(Composer.compose(ops), op));
  }

  private static DocOp insert(int location, int size) {
    return new DocOpBuilder()
        .retain(location)
        .characters("a")
        .retain(size - location)
        .build();
  }
View Full Code Here

        .retain(size - location)
        .build();
  }

  private static DocOp delete(int location, int size) {
    return new DocOpBuilder()
        .retain(location)
        .deleteCharacters("a")
        .retain(size - location)
        .build();
  }
View Full Code Here

      fail(e.toString());
    }
  }

  private static DocOp element(String tag) {
    return new DocOpBuilder().elementStart(tag, Attributes.EMPTY_MAP).elementEnd().build();
  }
View Full Code Here

  private static DocOp element(String tag) {
    return new DocOpBuilder().elementStart(tag, Attributes.EMPTY_MAP).elementEnd().build();
  }

  private static DocOp characters(String text, int location, int trail) {
    return new DocOpBuilder().retain(location).characters(text).retain(trail).build();
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.impl.DocOpBuilder

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.