Package org.waveprotocol.wave.model.operation.OpComparators

Examples of org.waveprotocol.wave.model.operation.OpComparators.OpEquator



  // This file focuses on negative tests. TODO: Add positive tests.

  public void testNullable() {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    assertTrue(eq.equalNullable((DocOp) null, null));
    assertFalse(eq.equalNullable(null, new DocOpBuffer().finish()));
    assertFalse(eq.equalNullable(new DocOpBuffer().finish(), null));

    try {
      eq.equal(new DocOpBuffer().finish(), null);
      fail();
    } catch (NullPointerException e) {
      // ok
    }

    try {
      eq.equal(null, new DocOpBuffer().finish());
      fail();
    } catch (NullPointerException e) {
      // ok
    }
  }
View Full Code Here


      // ok
    }
  }

  public void testDocOp() {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    DocOpBuffer ba1 = new DocOpBuffer();
    ba1.characters("a");
    DocOp a1 = ba1.finish();

    DocOpBuffer ba2 = new DocOpBuffer();
    ba2.characters("a");
    DocOp a2 = ba2.finish();

    DocOpBuffer bb1 = new DocOpBuffer();
    bb1.deleteCharacters("a");
    DocOp b1 = bb1.finish();

    DocOpBuffer bb2 = new DocOpBuffer();
    bb2.deleteCharacters("a");
    DocOp b2 = bb1.finish();

    assertTrue(eq.equal(a1, a1));
    assertTrue(eq.equal(a1, a2));
    assertTrue(eq.equal(a2, a1));
    assertTrue(eq.equal(a2, a2));

    assertTrue(eq.equal(b1, b1));
    assertTrue(eq.equal(b1, b2));
    assertTrue(eq.equal(b2, b1));
    assertTrue(eq.equal(b2, b2));

    assertFalse(eq.equal(a1, b1));
    assertFalse(eq.equal(a1, b2));
    assertFalse(eq.equal(a2, b1));
    assertFalse(eq.equal(a2, b2));
  }
View Full Code Here

    assertFalse("\ndoc1: " + DocOpUtil.toXmlString(doc1) + "\ndoc2: " + DocOpUtil.toXmlString(doc2),
        OpComparators.equalDocuments(doc1, doc2));
  }

  public void testRandomDocOps() throws OperationException {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    Parameters p = new Parameters();
    for (int i = 0; i < 200; i++) {
      BootstrapDocument doc = new BootstrapDocument();
      for (int j = 0; j < 20; j++) {
        RandomProvider ra = RandomProviderImpl.ofSeed(i * 20 + j);
        RandomProvider rb = RandomProviderImpl.ofSeed(i * 20 + j + 1);
        DocOp a = RandomDocOpGenerator.generate(ra, p, doc);
        DocOp b = RandomDocOpGenerator.generate(rb, p, doc);
        doc.consume(a);
        assertTrue(eq.equal(a, a));
        // The combination of RandomProvider and RandomDocOpGenerator doesn't
        // really guarantee this property, but it happens to be true with the
        // random seeds that occur here.
        assertFalse(eq.equal(a, b));
      }
    }
  }
View Full Code Here


public class CoreWaveletOperationEqualsTest extends TestCase {

  public void testTypes() {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    CoreWaveletOperation a = CoreNoOp.INSTANCE;
    CoreWaveletOperation b = new CoreAddParticipant(new ParticipantId(""));
    CoreWaveletOperation c = new CoreRemoveParticipant(new ParticipantId(""));
    CoreWaveletOperation d = new CoreWaveletDocumentOperation("", new DocOpBuffer().finish());
View Full Code Here

    assertFalse(d.equals(c));
    assertTrue (d.equals(d));
  }

  public void testAddParticipant() {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    CoreAddParticipant a1 = new CoreAddParticipant(new ParticipantId("a"));
    CoreAddParticipant a2 = new CoreAddParticipant(new ParticipantId("a"));
    CoreAddParticipant b1 = new CoreAddParticipant(new ParticipantId("b"));
    CoreAddParticipant b2 = new CoreAddParticipant(new ParticipantId("b"));
View Full Code Here

    assertFalse(a2.equals(b1));
    assertFalse(a2.equals(b2));
  }

  public void testRemoveParticipant() {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    CoreRemoveParticipant a1 = new CoreRemoveParticipant(new ParticipantId("a"));
    CoreRemoveParticipant a2 = new CoreRemoveParticipant(new ParticipantId("a"));
    CoreRemoveParticipant b1 = new CoreRemoveParticipant(new ParticipantId("b"));
    CoreRemoveParticipant b2 = new CoreRemoveParticipant(new ParticipantId("b"));
View Full Code Here

    assertFalse(a2.equals(b1));
    assertFalse(a2.equals(b2));
  }

  public void testWaveletDocumentOperationDocumentId() {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    DocOpBuffer b = new DocOpBuffer();
    b.characters("a");
    DocOp d = b.finish();
View Full Code Here

    assertFalse(a2.equals(b1));
    assertFalse(a2.equals(b2));
  }

  public void testWaveletDocumentOperationDocOp() {
    OpEquator eq = OpComparators.SYNTACTIC_IDENTITY;

    DocOpBuffer ba = new DocOpBuffer();
    ba.characters("a");
    DocOp da = ba.finish();
    DocOpBuffer bb = new DocOpBuffer();
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.operation.OpComparators.OpEquator

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.