Package org.waveprotocol.wave.model.wave

Examples of org.waveprotocol.wave.model.wave.ParticipantId


      return newData;
    }

    /** @return a sample wave with a conversation in it. */
    private static WaveViewData createSampleWave() {
      final ParticipantId sampleAuthor = ParticipantId.ofUnsafe("nobody@example.com");
      IdGenerator gen = FakeIdGenerator.create();
      final WaveViewDataImpl waveData = WaveViewDataImpl.create(gen.newWaveId());
      final DocumentFactory<?> docFactory = BasicFactories.fakeDocumentFactory();
      final ObservableWaveletData.Factory<?> waveletDataFactory =
          new ObservableWaveletData.Factory<WaveletDataImpl>() {
View Full Code Here


    assertEquals(creator, add.getContext().getCreator());
    assertEquals(participant, add.getParticipantId());
  }

  public void testAddingCreatorAsParticipantProducesOperation() {
    ParticipantId creator = target.getCreatorId();
    target.addParticipant(creator);

    assertTrue(sink.getConsumedOp() instanceof AddParticipant);
    assertEquals(creator, ((AddParticipant) sink.getConsumedOp()).getParticipantId());
  }
View Full Code Here

  public void testAddingParticipantIdSetProducesManyOperations() {
    target.addParticipant(target.getCreatorId());
    Set<ParticipantId> participants = new HashSet<ParticipantId>();
    for (int i = 0; i < 20; i++) {
      ParticipantId participant = new ParticipantId("foo" + i + "@bar.com");
      participants.add(participant);
    }
    target.addParticipantIds(participants);
    List<WaveletOperation> operations = sink.getOps();
    for (WaveletOperation op : operations) {
View Full Code Here

  public void testAddingManyParticipantProducesManyOperations() {
    // Creator must be added as first op.
    target.addParticipant(target.getCreatorId());
    for (int i = 0; i < 20; i++) {
      ParticipantId participant = new ParticipantId("foo" + i + "@bar.com");
      target.addParticipant(participant);
      assertTrue(sink.getConsumedOp() instanceof AddParticipant);
      assertEquals(participant, ((AddParticipant) sink.getConsumedOp()).getParticipantId());
      sink.clear();
    }
View Full Code Here

   * Tests the situation where someone not on a wavelet's participant list
   * attempts to perform some operation. Ensures that the model adds them as a
   * participant before the attempted operations go through.
   */
  public void testNonParticipantAutoAddedByAuthoriser() {
    final ParticipantId creator = target.getCreatorId();
    final ParticipantId bob = new ParticipantId("bob@example.com");

    target.addParticipant(target.getCreatorId());

    sink.clear();
    factory.getLastContextFactory().setParticipantId(bob);
View Full Code Here

   * single add-participant operation is generated.  This should be in the form
   * of addParticipant suppressing the given operation and only performing the
   * auto-injected one.
   */
  public void testNonParticipantAutoAddedByAuthoriserSuppressesDuplicateAddParticipantOp() {
    final ParticipantId creator = target.getCreatorId();
    final ParticipantId fred = new ParticipantId("fred@google.com");

    target.addParticipant(target.getCreatorId());
    OpBasedBlip root = target.createBlip("b+fake");

    sink.clear();
View Full Code Here

   * Like {@link #testNonParticipantAutoAddedByAuthoriser()}, but tests that,
   * even though a user adding themselves suppresses duplicate operations, it
   * doesn't suppress all add-participant ops.
   */
  public void testNonParticipantAutoAddedByAuthoriserDoesntSuppressAddParticipantOp() {
    final ParticipantId creator = target.getCreatorId();
    final ParticipantId fred = new ParticipantId("fred@google.com");
    final ParticipantId gary = new ParticipantId("gary@google.com");

    target.addParticipant(target.getCreatorId());
    OpBasedBlip root = target.createBlip("b+fake");

    sink.clear();
View Full Code Here

      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

        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

    final ParticipantId creator;

    List<AggregateOperation> ops = new ArrayList<AggregateOperation>();

    WaveOpBuilder(String userName) {
      creator = new ParticipantId(userName);
    }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.wave.ParticipantId

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.