Package org.waveprotocol.wave.model.document.operation.util.ImmutableUpdateMap

Examples of org.waveprotocol.wave.model.document.operation.util.ImmutableUpdateMap.AttributeUpdate


  public static AttributesUpdate scrubAttributesUpdate(AttributesUpdate unscrubbed,
      ScrubCache nameScrubber) {
    List<AttributeUpdate> list = new ArrayList<AttributeUpdate>();
    for (int i = 0; i < unscrubbed.changeSize(); i++) {
      list.add(new AttributeUpdate(
          nameScrubber.scrubUniquely(unscrubbed.getChangeKey(i)),
          scrubMostString(unscrubbed.getOldValue(i)),
          scrubMostString(unscrubbed.getNewValue(i))));
    }
    return AttributesUpdateImpl.fromUnsortedUpdatesUnchecked(list);
View Full Code Here


public class ImmutableUpdateMapTest extends TestCase {

  public void testCheckUpdatesSorted() {
    // see also the corresponding tests in ImmutableStateMapTest.
    ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(new AttributeUpdate[] {}));
    ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(new AttributeUpdate("a", null, "1")));
    ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
        new AttributeUpdate("aa", "0", "1"),
        new AttributeUpdate("ab", null, null)));
    ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
        new AttributeUpdate("a", "0", null),
        new AttributeUpdate("b", "p", "2"),
        new AttributeUpdate("c", "1", "1")));
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("asdfa", "a", "1"),
          new AttributeUpdate("asdfb", "2", null),
          new AttributeUpdate("asdfb", "2", "3")));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("rar", null, "1"),
          new AttributeUpdate("rar", "2", null),
          new AttributeUpdate("rbr", "1", "2")));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          null,
          new AttributeUpdate("a", "2", "1")));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("a", "2", "a"),
          null));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("a", "1", "j"),
          new AttributeUpdate("a", "1", "r")));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("a", "1", "f"),
          null,
          new AttributeUpdate("c", "a", "1")));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          null,
          new AttributeUpdate("a", "1", "o"),
          new AttributeUpdate("c", "1", "l")));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("a", "1", "y"),
          new AttributeUpdate("c", "1", ";"),
          null));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("ard", "1", "3"),
          new AttributeUpdate("ard", "1", "2"),
          null));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableUpdateMap.checkUpdatesSorted(Arrays.asList(
          new AttributeUpdate("a", "1", null),
          new AttributeUpdate("c", "2", null),
          new AttributeUpdate("b", "3", null)));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
  }
View Full Code Here

  private AttributesUpdate attributesUpdateFrom(UpdateAttributes message) {
    List<AttributeUpdate> updates = new ArrayList<AttributeUpdate>();
    for (int i = 0; i < message.getAttributeUpdateSize(); i++) {
      KeyValueUpdate p = message.getAttributeUpdate(i);
      updates.add(new AttributeUpdate(p.getKey(), p.hasOldValue() ? p.getOldValue() : null,
          p.hasNewValue() ? p.getNewValue() : null));
    }
    return createAttributesUpdateImpl(updates);
  }
View Full Code Here

  public static AttributesUpdate scrubAttributesUpdate(AttributesUpdate unscrubbed,
      ScrubCache nameScrubber) {
    List<AttributeUpdate> list = new ArrayList<AttributeUpdate>();
    for (int i = 0; i < unscrubbed.changeSize(); i++) {
      list.add(new AttributeUpdate(
          nameScrubber.scrubUniquely(unscrubbed.getChangeKey(i)),
          scrubMostString(unscrubbed.getOldValue(i)),
          scrubMostString(unscrubbed.getNewValue(i))));
    }
    return AttributesUpdateImpl.fromUnsortedUpdatesUnchecked(list);
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.util.ImmutableUpdateMap.AttributeUpdate

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.