Examples of DeltaTestUtil


Examples of org.waveprotocol.wave.model.testing.DeltaTestUtil

    // Ack the configurator's add-participant
    assertEquals(1, waveViewService.submits.size());
    waveViewService.lastSubmit().callback
        .onSuccess(HashedVersion.of(1L, sig(111)), 1, null, ResponseCode.OK);

    DeltaTestUtil util = new DeltaTestUtil(USER_ID);

    // Receive an operation from the server that doesn't affect the document.
    TransformedWaveletDelta delta1 =
        util.delta(1L, util.addParticipant(new ParticipantId("reuben@example.com")));
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(GENERATED_WAVELET_ID).addDelta(delta1));

    assertEquals(2, createdWavelet.getParticipantIds().size());

    // create an empty blip edit (i.e. implicit creation) and expect flush
    TransformedWaveletDelta delta2 = util.delta(2L, util.noOpDocOp(GENERATED_BLIP_ID));
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(GENERATED_WAVELET_ID).addDelta(delta2));
    doc.expectedCall(MockCcDocument.MethodCall.FLUSH);
    doc.expectedCall(MockCcDocument.MethodCall.CONSUME);
    doc.expectedNothing();

    // now hold back flush on another server op
    doc.flush_return = false;
    TransformedWaveletDelta delta3 = util.delta(3L, util.noOpDocOp(GENERATED_BLIP_ID));
    openCallback.onUpdate(new FakeWaveViewServiceUpdate()
        .setWaveletId(GENERATED_WAVELET_ID).addDelta(delta3));
    MockCcDocument.MethodCallContext callContext =
        doc.expectedCall(MockCcDocument.MethodCall.FLUSH);
    doc.expectedNothing();
View Full Code Here

Examples of org.waveprotocol.wave.model.testing.DeltaTestUtil

  /**
   * Test we still compose operations after we've transformed.
   */
  public void testComposistionAfterTransform() throws TransformException {
    DeltaTestUtil util = new DeltaTestUtil(BOB);

    // 2 ops merged into one.
    queue.add(util.noOpDocOp("blipA"));
    queue.add(util.noOpDocOp("blipA"));

    // Get a server op
    transformer.expect(util.noOpDocOp("blipA")).echo();
    assertEquals(transformer.getOutputServerDelta(), // \u2620
        queue.transform(transformer.getInputServerDelta()));

    // Adding one more operation after that should not merge into previously
    // transformed client op
    queue.add(util.noOpDocOp("blipA"));

    // This operation should merge into the previous op as the previous op is not
    // yet transformed
    queue.add(util.noOpDocOp("blipA"));

    // Should get 1 op, the result of merging and composing the two deltas.
    assertQueueSizeBetween(1, 3);
    assertEquals(list(util.noOpDocOp("blipA")), copyList(queue.take()));

    assertQueueIsEmpty();
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.testing.DeltaTestUtil

    assertQueueIsEmpty();
  }

  public void testCompositionBeforeTransform() throws TransformException {
    DeltaTestUtil util = new DeltaTestUtil(BOB);

    // 2 ops merged into one.
    queue.add(util.noOpDocOp("blipA"));
    queue.add(util.noOpDocOp("blipA"));

    // Get a server op
    transformer.expect(util.noOpDocOp("blipA")).echo();
    assertEquals(transformer.getOutputServerDelta(), // \u2620
        queue.transform(transformer.getInputServerDelta()));

    // Should get only 1 op
    assertQueueSize(1);
    assertEquals(list(util.noOpDocOp("blipA")), copyList(queue.take()));

    assertQueueIsEmpty();
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.testing.DeltaTestUtil

  /**
   * Test we compose operations after we've transformed. However, we should get several
   * transformed client operations out in the same delta if they don't compose.
   */
  public void testGettingSeveralOpsInOneDelta() throws TransformException {
    DeltaTestUtil util = new DeltaTestUtil(BOB);

    // Do 1 client op
    queue.add(util.noOpDocOp("blipA"));

    // Get a server op
    transformer.expect(util.noOpDocOp("blipA")).echo();
    assertEquals(transformer.getOutputServerDelta(), // \u2620
        queue.transform(transformer.getInputServerDelta()));

    // Do another client op
    queue.add(util.noOpDocOp("blipB"));

    // Get a server op
    transformer.expect(util.noOpDocOp("blipA"), util.noOpDocOp("blipB")).echo();
    assertEquals(transformer.getOutputServerDelta(), // \u2620
        queue.transform(transformer.getInputServerDelta()));

    // Should get 2 ops in the same delta
    assertQueueSizeBetween(1, 2);
    assertEquals(list(util.noOpDocOp("blipA"), util.noOpDocOp("blipB")), copyList(queue.take()));

    assertQueueIsEmpty();
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.testing.DeltaTestUtil

  /**
   * Since transform and compose doesn't commute, test we don't compose operations after
   * we've sent the operation. So when we push to head, we shouldn't merge sent deltas.
   */
  public void testNoCompositionWithInsertHead() throws TransformException {
    DeltaTestUtil util = new DeltaTestUtil(BOB);

    // Do 1 client op
    queue.add(util.noOpDocOp("blipA"));
    // Pushing an op to the head should never merge
    queue.insertHead(Arrays.asList(util.noOpDocOp("blipA")));

    // Get a server op
    transformer.expect(util.noOpDocOp("blipA")).echo();
    transformer.expect(util.noOpDocOp("blipA")).echo();
    assertEquals(transformer.getOutputServerDelta(), // \u2620
        queue.transform(transformer.getInputServerDelta()));


    // Should be 2 deltas a the first one is not mergable
    assertQueueSizeBetween(1, 2);
    assertEquals(list(util.noOpDocOp("blipA")), copyList(queue.take()));
    assertEquals(list(util.noOpDocOp("blipA")), copyList(queue.take()));

    assertQueueIsEmpty();
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.testing.DeltaTestUtil

  /**
   * Test operations are actually transformed.
   */
  public void testOpsAreTransformed() throws TransformException {
    queue = new OperationQueue();
    DeltaTestUtil bob = new DeltaTestUtil(BOB);
    DeltaTestUtil jim = new DeltaTestUtil(JIM);

    // Do bob client op 1
    queue.add(bob.insert(1, "a", 1, null));

    // Get delta 1 from jim
    queue.transform(Arrays.asList(jim.insert(1, "j", 1, null)));

    // Do bob client op 2
    queue.add(bob.insert(1, "b", 3, null));

    // Get delta 2 from jim
    queue.transform(Arrays.asList(jim.insert(1, "i", 2, null)));

    // check ops are transformed
    assertEquals(list(bob.insert(1, "ba", 3, null)), copyList(queue.take()));

    assertQueueIsEmpty();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.