Package org.waveprotocol.wave.model.wave.data

Examples of org.waveprotocol.wave.model.wave.data.WaveletData


  }

  public void testDisallowedUserReturnsForbidden() throws Exception {
    waveletProvider.setAllowsAccess(false);

    WaveletData wavelet = waveletProvider.getHostedWavelet();
    WaveRef waveref = WaveRef.of(wavelet.getWaveId(), wavelet.getWaveletId());
    verifyServletReturnsForbiddenForWaveref(waveref);
  }
View Full Code Here


  private ObservableWaveletData build(TransformedWaveletDelta... deltas) throws OperationException {
    return WaveletDataUtil.buildWaveletFromDeltas(WAVELET_NAME, Arrays.asList(deltas).iterator());
  }

  public void testBuildWaveletFromOneDelta() throws Exception {
    WaveletData wavelet = build(
        delta(addParticipant(CREATOR, 1093L, HashedVersion.unsigned(1)))
    );
    assertEquals(WAVELET_NAME, WaveletDataUtil.waveletNameOf(wavelet));
    assertEquals(CREATOR, wavelet.getCreator());
    assertEquals(1093L, wavelet.getCreationTime());
    assertEquals(1093L, wavelet.getLastModifiedTime());
    assertEquals(HashedVersion.unsigned(1), wavelet.getHashedVersion());
    assertEquals(ImmutableSet.of(), wavelet.getDocumentIds());
    assertEquals(ImmutableSet.of(CREATOR), wavelet.getParticipants());
  }
View Full Code Here

    WaveRef waveref = WaveRef.of(wavelet.getWaveId(), wavelet.getWaveletId());
    verifyServletReturnsForbiddenForWaveref(waveref);
  }

  public void testGetMissingDataReturnsForbidden() throws Exception {
    WaveletData wavelet = waveletProvider.getHostedWavelet();
    WaveId waveId = wavelet.getWaveId();
    WaveletId waveletId = wavelet.getWaveletId();

    WaveRef unknownWave = WaveRef.of(WaveId.of(waveId.getDomain(), waveId.getId() + "junk"));
    verifyServletReturnsForbiddenForWaveref(unknownWave);
    WaveRef unknownWavelet = WaveRef.of(waveId, WaveletId.of(waveletId.getDomain(), waveletId.getId() + "junk"));
    verifyServletReturnsForbiddenForWaveref(unknownWavelet);
View Full Code Here

   * Round-trip a wavelet and make sure all the fields match.
   * We only check the fields that WaveletSnapshot serializes.
   * @throws Exception
   */
  public void testGetWavelet() throws Exception {
    WaveletData wavelet = waveletProvider.getHostedWavelet();

    WaveRef waveref = WaveRef.of(wavelet.getWaveId(), wavelet.getWaveletId());
    WaveletSnapshot snapshot = fetchWaverRefAndParse(waveref, WaveletSnapshot.class);
    WaveletData roundtripped = SnapshotSerializer.deserializeWavelet(snapshot, waveref.getWaveId());

    // We have just round-tripped wavelet through the servlet. wavelet and
    // roundtripped should be identical in all the fields that get serialized.
    TestDataUtil.checkSerializedWavelet(wavelet, roundtripped);

View Full Code Here

    assertEquals(ImmutableSet.of(), wavelet.getDocumentIds());
    assertEquals(ImmutableSet.of(CREATOR), wavelet.getParticipants());
  }

  public void testBuildWaveletFromThreeDeltas() throws Exception {
    WaveletData wavelet = build(
        delta(addParticipant(CREATOR, 1093L, HashedVersion.unsigned(1))),
        delta(addParticipant(JOE, 1492L, HashedVersion.unsigned(2))),
        delta(addBlip("blipid", 2010L, HashedVersion.unsigned(3)))
    );
    assertEquals(WAVELET_NAME, WaveletDataUtil.waveletNameOf(wavelet));
    assertEquals(CREATOR, wavelet.getCreator());
    assertEquals(1093L, wavelet.getCreationTime());
    assertEquals(2010L, wavelet.getLastModifiedTime());
    assertEquals(HashedVersion.unsigned(3), wavelet.getHashedVersion());
    assertEquals(ImmutableSet.of("blipid"), wavelet.getDocumentIds());
    assertEquals(ImmutableSet.of(CREATOR, JOE), wavelet.getParticipants());
  }
View Full Code Here

   * (/fetch/domain/waveid/domain/waveletid/docid).
   *
   * @throws Exception
   */
  public void testGetDocument() throws Exception {
    WaveletData wavelet = waveletProvider.getHostedWavelet();
    for (String docId : wavelet.getDocumentIds()) {
      // We currently have no way to deserialize a document. Instead, we'll
      // serialize the expected document and compare with what we get from the
      // fetch servlet.
      StringWriter writer = new StringWriter();
      BlipData expectedDoc = wavelet.getDocument(docId);
      writer.append("" + protoSerializer.toJson(SnapshotSerializer.serializeDocument(expectedDoc)));
      String expectedResult = writer.toString();

      WaveRef waveref = WaveRef.of(wavelet.getWaveId(), wavelet.getWaveletId(), docId);
      String actualResult = fetchWaveRef(waveref);

      assertEquals(expectedResult, actualResult);
    }
  }
View Full Code Here

    WaveletName name = WaveletName.of(
        WaveId.of("example.com", "w+abc123"), WaveletId.of("example.com", "conv+root"));
    ParticipantId creator = ParticipantId.ofUnsafe("sam@example.com");
    long time = 1234567890;

    WaveletData wavelet = WaveletDataUtil.createEmptyWavelet(name, creator,
        HashedVersion.unsigned(0), time);

    DocInitialization content = new DocInitializationBuilder().characters("Hello there").build();
    wavelet.createDocument(
        "b+abc123", creator, Collections.<ParticipantId> emptySet(), content, time, 0);

    return wavelet;
  }
View Full Code Here

      return new DeltaStoreBasedWaveletState(deltasAccess, ImmutableList.<WaveletDeltaRecord>of(),
          null, persistExecutor);
    } else {
      try {
        ImmutableList<WaveletDeltaRecord> deltas = readAll(deltasAccess, null);
        WaveletData snapshot = WaveletDataUtil.buildWaveletFromDeltas(deltasAccess.getWaveletName(),
            Iterators.transform(deltas.iterator(), TRANSFORMED));
        return new DeltaStoreBasedWaveletState(deltasAccess, deltas, snapshot, persistExecutor);
      } catch (IOException e) {
        throw new PersistenceException("Failed to read stored deltas", e);
      } catch (OperationException e) {
View Full Code Here

    if (wavelets == null) {
      wavelets = Maps.newHashMap();
      waves.put(waveletName.waveId, wavelets);
    }

    WaveletData wavelet = wavelets.get(waveletName.waveletId);
    if (wavelet == null) {
      long dummyCreationTime = System.currentTimeMillis();
      wavelet = WaveletDataUtil.createEmptyWavelet(
          waveletName, ParticipantId.ofUnsafe(delta.getAuthor()),
          HashedVersion.unsigned(0), dummyCreationTime);
View Full Code Here

    if (wavelets == null) {
      wavelets = Maps.newHashMap();
      waves.put(waveletName.waveId, wavelets);
    }

    WaveletData wavelet = wavelets.get(waveletName.waveletId);
    if (wavelet == null) {
      long dummyCreationTime = System.currentTimeMillis();
      wavelet = WaveletDataUtil.createEmptyWavelet(
          waveletName, ParticipantId.ofUnsafe(delta.getAuthor()),
          HashedVersion.unsigned(0), dummyCreationTime);
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.wave.data.WaveletData

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.