Examples of AddParticipant


Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

    assertEquals(ALEX, delta.getAuthor());

    assertTrue(delta.size() == 1);

    AddParticipant addParticipantOp = new AddParticipant(null, TRIXIE);
    assertEquals("Expected operation that adds Trixie to the wavelet", addParticipantOp,
        delta.iterator().next());
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

    // We are making an delta which applies to version 1, however the robot only
    // knows about version 0.
    ParticipantId bob = ParticipantId.of("bob@exmaple.com");
    HashedVersion v2 = HashedVersion.unsigned(2);
    WaveletOperation addBob = new AddParticipant(new WaveletOperationContext(ALEX, 0L, 1, v2), bob);
    addBob.apply(waveletData);
    waveletData.setHashedVersion(v2);
    waveletData.setVersion(2);

    TransformedWaveletDelta delta = new TransformedWaveletDelta(ALEX, v2,
        0L, Collections.singletonList(addBob));
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

    List<WaveletDelta> deltas = newWavelet.getDeltas();
    boolean seenAddAlex = false;
    boolean seenAddBob = false;
    for (WaveletOperation op : deltas.get(0)) {
      if (op instanceof AddParticipant) {
        AddParticipant addParticipant = (AddParticipant) op;
        if (addParticipant.getParticipantId().equals(ALEX)) {
          seenAddAlex = true;
        } else if (addParticipant.getParticipantId().equals(BOB)) {
          seenAddBob = true;
        } else {
          fail("No one else but Alex and Bob should be added");
        }
      }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

  protected void setUp() throws Exception {
    waveletData = WaveletDataUtil.createEmptyWavelet(WAVELET_NAME, ALEX, HashedVersion.unsigned(0),
        0L);
    waveletData.addParticipant(ALEX);

    AddParticipant addBobOp = new AddParticipant(new WaveletOperationContext(ALEX, 0L, 1, V1), BOB);

    addBobOp.apply(waveletData);
    TransformedWaveletDelta delta =
        new TransformedWaveletDelta(ALEX, V1, 0L, Arrays.asList(addBobOp));

    wavelet = WaveletAndDeltas.create(waveletData, DeltaSequence.of(delta));
    addCarolOp = new AddParticipant(new WaveletOperationContext(ALEX, 0L, 1, V2), CAROL);
    removeAlexOp = new RemoveParticipant(new WaveletOperationContext(ALEX, 0L, 1, V3), ALEX);
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

   */
  private static void assertAddParticipant(ParticipantId creator,
      ParticipantId participant, WaveletOperation op) {
    assertTrue("Expected AddParticipant but was " + op.getClass(),
        op instanceof AddParticipant);
    AddParticipant add = (AddParticipant) op;
    assertEquals(creator, add.getContext().getCreator());
    assertEquals(participant, add.getParticipantId());
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

      WaveAggregateOp op2 = new WaveOpBuilder(CREATOR2_ID).addParticipant(TARGET2).build();

      WaveAggregateOp composed = compose(op1, op2);

      List<WaveletOperation> expected = Arrays.<WaveletOperation>asList(
          new AddParticipant(CREATOR1_CONTEXT, new ParticipantId(TARGET1)),
          new AddParticipant(CREATOR2_CONTEXT, new ParticipantId(TARGET2))
      );
      assertEquals(expected, composed.toWaveletOperations());
    }

    {
      DocOp insertDocOp = insertDocOp(1, 5);
      WaveAggregateOp op1 = new WaveOpBuilder(CREATOR1_ID).addParticipant(TARGET1).build();
      WaveAggregateOp op2 = new WaveOpBuilder(CREATOR2_ID).docOp("doc", insertDocOp).build();


      WaveAggregateOp composed = compose(op1, op2);

      List<WaveletOperation> expected = Arrays.<WaveletOperation>asList(
          new AddParticipant(CREATOR1_CONTEXT, new ParticipantId(TARGET1)),
          new WaveletBlipOperation("doc", new BlipContentOperation(CREATOR2_CONTEXT, insertDocOp))
      );
      assertEquals(expected, composed.toWaveletOperations());
    }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

        fail("transform failed:" + e);
        return;
      }

      List<WaveletOperation> expectedClient = Arrays.<WaveletOperation> asList(
          new AddParticipant(CREATOR1_CONTEXT, new ParticipantId(TARGET1)));
      List<WaveletOperation> expectedServer = Arrays.<WaveletOperation> asList(
          new AddParticipant(CREATOR2_CONTEXT, new ParticipantId(TARGET2)));

      assertEquals(expectedClient, transformed.clientOp().toWaveletOperations());
      assertEquals(expectedServer, transformed.serverOp().toWaveletOperations());
    }

    // Test case where client ops are transformed away, and some server ops are kept
    {
      WaveAggregateOp op1 = new WaveOpBuilder(CREATOR1_ID).addParticipant(TARGET1).build();
      WaveAggregateOp op2 =
          new WaveOpBuilder(CREATOR2_ID).addParticipant(TARGET1).addParticipant(TARGET2).build();

      OperationPair<WaveAggregateOp> transformed;
      try {
        transformed = WaveAggregateOp.transform(op1, op2);
      } catch (TransformException e) {
        fail("transform failed:" + e);
        return;
      }

      List<WaveletOperation> expectedServer =
          Arrays.<WaveletOperation> asList(new AddParticipant(CREATOR2_CONTEXT, new ParticipantId(
              TARGET2)));

      assertEquals(0, transformed.clientOp().toWaveletOperations().size());
      assertEquals(expectedServer, transformed.serverOp().toWaveletOperations());
    }

    // Same as above, but server ops originate from 2 different creators. Test
    // that the creators are preserved correctly through transform and
    // composition.
    {
      WaveAggregateOp op1 = new WaveOpBuilder(CREATOR1_ID).addParticipant(TARGET1).build();
      WaveAggregateOp op2a =
          new WaveOpBuilder(CREATOR2_ID).addParticipant(TARGET1).build();
      WaveAggregateOp op2b = new WaveOpBuilder(CREATOR1_ID).addParticipant(TARGET2).build();
      WaveAggregateOp op2 = compose(op2a, op2b);

      OperationPair<WaveAggregateOp> transformed;
      try {
        transformed = WaveAggregateOp.transform(op1, op2);
      } catch (TransformException e) {
        fail("transform failed:" + e);
        return;
      }

      List<WaveletOperation> expectedServer =
          Arrays.<WaveletOperation> asList(new AddParticipant(CREATOR1_CONTEXT, new ParticipantId(
              TARGET2)));

      assertEquals(0, transformed.clientOp().toWaveletOperations().size());
      assertEquals(expectedServer, transformed.serverOp().toWaveletOperations());
    }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

    assertEquals(2, fakeUnsavedDataListener.closeCalls);
  }

  private AddParticipant createAddParticipantOp(String participantName) {
    AddParticipant addPart = new AddParticipant(new WaveletOperationContext(
        USER_NAME, -1L, 0L), new ParticipantId(participantName));
    return addPart;
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

    MergingSequence delta = new MergingSequence();
    ParticipantId jim = new ParticipantId("jim");
    delta.addAll(Arrays.asList(
        makeBlipContentOp("a", 1),
        makeBlipContentOp("a", 2),
        new AddParticipant(new WaveletOperationContext(jim, 5L, 1L), jim)
    ));

    delta.optimise();

    assertEquals(2, delta.size());
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.wave.AddParticipant

    MergingSequence delta = new MergingSequence();
    ParticipantId jim = new ParticipantId("jim");
    delta.addAll(Arrays.asList(
        makeBlipContentOp("a", 1),
        makeBlipContentOp("a", 2),
        new AddParticipant(new WaveletOperationContext(jim, 5L, 1L), jim),
        makeBlipContentOp("a", 4),
        makeBlipContentOp("a", 5)
    ));

    delta.optimise();
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.