Package org.waveprotocol.wave.model.document.operation.impl

Examples of org.waveprotocol.wave.model.document.operation.impl.AttributesUpdateImpl


      void resolveUpdateAttributes(AttributesUpdate update) {
        Map<String, String> updated = new HashMap<String, String>();
        for (int i = 0; i < update.changeSize(); ++i) {
          updated.put(update.getChangeKey(i), update.getNewValue(i));
        }
        AttributesUpdate newUpdate = new AttributesUpdateImpl();
        // TODO: This is a little silly. We should do this a better way.
        for (int i = 0; i < this.update.changeSize(); ++i) {
          String key = this.update.getChangeKey(i);
          String newOldValue = updated.containsKey(key) ? updated.get(key)
              : this.update.getOldValue(i);
          newUpdate = newUpdate.composeWith(new AttributesUpdateImpl(key,
              newOldValue, this.update.getNewValue(i)));
        }
        targetDocument.updateAttributes(newUpdate);
        Set<String> keySet = new HashSet<String>();
        for (int i = 0; i < this.update.changeSize(); ++i) {
View Full Code Here


*/
public class ImmutableStateMapTest extends TestCase {

  public void testRemovalInUpdateWith() {
    assertFalse(new AttributesImpl("a", "1").updateWith(
        new AttributesUpdateImpl("a", "1", null)).containsKey("a"));
  }
View Full Code Here

  }

  public void testUpdate() {
    Map<String, String> m = new HashMap<String, String>();
    m.put("a", "0");
    AttributesImpl a = new AttributesImpl(m).updateWith(new AttributesUpdateImpl("b", null, "1"));
    assertEquals("0", a.get("a"));
    assertEquals("1", a.get("b"));
    assertEquals(2, a.size());
  }
View Full Code Here

    doc.consume(TEST_DOC1);
    check(TEST_DOC1_XML, doc);

    doc.consume(new DocOpBuffer() {
      {
        updateAttributes(new AttributesUpdateImpl("a", null, "2"));
        deleteCharacters("hi t");
        characters("you ");
        retain(4);
        replaceAttributes(new AttributesImpl("a", "1"), new AttributesImpl("b", "2"));
        retain("<some>markup&".length() + 1);
        updateAttributes(new AttributesUpdateImpl("a", "2", "3"));
        retain(2);
        annotationBoundary(AnnotationBoundaryMapImpl.builder().updateValues(
            "link", "12?\"\\3", "blah").build());
        retain(3);
        annotationBoundary(AnnotationBoundaryMapImpl.builder().initializationEnd("link").build());
View Full Code Here

    checkAttributes(validator, Type.ATTRIBUTE_NOT_ALLOWED, new AttributesImpl(
        "a1", "v1",
        "a2", "v2",
        "bad", "bad"));
    checkUpdate(validator, Type.VALID, AttributesUpdateImpl.EMPTY_MAP);
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.INVALID_ATTRIBUTE_VALUE, new AttributesUpdateImpl(
        "a1", "v2", "v2",
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.INVALID_ATTRIBUTE_VALUE, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v1", "v1"));
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a1", "v1", "v1"));
    checkUpdate(validator, Type.ATTRIBUTE_NOT_ALLOWED, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v2", "v2",
        "bad", "bad", "bad"));
    checkUpdate(validator, Type.REMOVING_REQUIRED_ATTRIBUTE, new AttributesUpdateImpl(
        "a1", "v1", null,
        "a2", "v2", "v2"));
  }
View Full Code Here

    checkAttributes(validator, Type.ATTRIBUTE_NOT_ALLOWED, new AttributesImpl(
        "a1", "v1",
        "a2", "v2",
        "bad", "bad"));
    checkUpdate(validator, Type.VALID, AttributesUpdateImpl.EMPTY_MAP);
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.INVALID_ATTRIBUTE_VALUE, new AttributesUpdateImpl(
        "a1", "v2", "v2",
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.INVALID_ATTRIBUTE_VALUE, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v1", "v1"));
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a1", "v1", "v1"));
    checkUpdate(validator, Type.ATTRIBUTE_NOT_ALLOWED, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v2", "v2",
        "bad", "bad", "bad"));
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a1", "v1", null,
        "a2", "v2", "v2"));
  }
View Full Code Here

    checkAttributes(validator, Type.ATTRIBUTE_NOT_ALLOWED, new AttributesImpl(
        "a1", "v1",
        "a2", "v2",
        "bad", "bad"));
    checkUpdate(validator, Type.VALID, AttributesUpdateImpl.EMPTY_MAP);
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.INVALID_ATTRIBUTE_VALUE, new AttributesUpdateImpl(
        "a1", "v2", "v2",
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.INVALID_ATTRIBUTE_VALUE, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v1", "v1"));
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a2", "v2", "v2"));
    checkUpdate(validator, Type.VALID, new AttributesUpdateImpl(
        "a1", "v1", "v1"));
    checkUpdate(validator, Type.ATTRIBUTE_NOT_ALLOWED, new AttributesUpdateImpl(
        "a1", "v1", "v1",
        "a2", "v2", "v2",
        "bad", "bad", "bad"));
    checkUpdate(validator, Type.REMOVING_REQUIRED_ATTRIBUTE, new AttributesUpdateImpl(
        "a1", "v1", null,
        "a2", "v2", "v2"));
  }
View Full Code Here

      currentLocation++;
      currentContainer = currentContainer.getNextContainer();
      currentParent = node;
      annotations.skip(1);

      AttributesUpdateImpl attrUpdate = new AttributesUpdateImpl(triples);
      builder.updateAttributes(attrUpdate);
      onModifyAttributes(currentParent, attrUpdate);
    }
View Full Code Here

  }

  public void testUpdateAttributes() {
    DocOpBuilder m = new DocOpBuilder();

    AttributesUpdate u = new AttributesUpdateImpl(new String[]{"a", null, "2", "b", "1", null});

    m.retain(4);
    m.updateAttributes(u);
    m.retain(4);
View Full Code Here

    checkValidation_V(test_element1.validateAttributes(AttributesImpl.EMPTY_MAP));
    checkValidation_ANA(test_element1.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "bad", "bad")),
        "bad");
    checkValidation_ANA(test_element1.validateAttributesUpdate(new AttributesUpdateImpl(
        "bad", "value1", "value1")),
        "bad");
    checkValidation_IAV(test_element1.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute1", "bad", "bad")),
        "attribute1", "bad");
    checkValidation_V(test_element1.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute1", "value1", "value1")));
    checkValidation_V(test_element1.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute1", null, "value1")));
    checkValidation_V(test_element1.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute1", "value1", null)));
    checkValidation_V(test_element1.validateAttributesUpdate(AttributesUpdateImpl.EMPTY_MAP));
    checkValidation_ANA(test_element1.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute1", "value1", "value1",
        "bad", "bad", "bad")),
        "bad");

    /*
     * Test a pattern containing a single non-required attribute with an
     * infinite number of possible values matching a regular expression.
     */
    SchemaPattern test_element2 = test.child("element2");
    checkValidation_ANA(test_element2.validateAttributes(new AttributesImpl(
        "bad", "abbbc")),
        "bad");
    checkValidation_IAV(test_element2.validateAttributes(new AttributesImpl(
        "attribute2", "bad")),
        "attribute2", "bad");
    checkValidation_V(test_element2.validateAttributes(new AttributesImpl(
        "attribute2", "abbbc")));
    checkValidation_ANA(test_element2.validateAttributesUpdate(new AttributesUpdateImpl(
        "bad", "abbbc", "abbbc")),
        "bad");
    checkValidation_IAV(test_element2.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute2", "bad", "bad")),
        "attribute2", "bad");
    checkValidation_V(test_element2.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute2", "abbbc", "abbbc")));
    checkValidation_V(test_element2.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute2", null, "abbbc")));
    checkValidation_V(test_element2.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute2", "abbbc", null)));

    /*
     * Test a pattern containing a mixture of required and non-required attributes.
     */
    SchemaPattern test_element3 = test.child("element3");
    checkValidation_MRA(test_element3.validateAttributes(new AttributesImpl(
        "bad", "value1")),
        "attribute3");
    checkValidation_ANA(test_element3.validateAttributes(new AttributesImpl(
        "attribute3", "value3",
        "bad", "bad")),
        "bad");
    checkValidation_V(test_element3.validateAttributes(new AttributesImpl(
        "attribute3", "value3")));
    checkValidation_V(test_element3.validateAttributes(new AttributesImpl(
        "attribute3", "value3",
        "attribute4", "value4",
        "attribute5", "value5")));
    checkValidation_IAV(test_element3.validateAttributes(new AttributesImpl(
        "attribute3", "bad",
        "attribute4", "value4",
        "attribute5", "value5")),
        "attribute3", "bad");
    checkValidation_IAV(test_element3.validateAttributes(new AttributesImpl(
        "attribute3", "value3",
        "attribute4", "bad",
        "attribute5", "value5")),
        "attribute4", "bad");
    checkValidation_MRA(test_element3.validateAttributes(new AttributesImpl(
        "attribute4", "value4",
        "attribute5", "value5")),
        "attribute3");
    checkValidation_MRA(test_element3.validateAttributes(AttributesImpl.EMPTY_MAP),
        "attribute3");
    checkValidation_ANA(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "bad", "value1", "value1")),
        "bad");
    checkValidation_ANA(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute3", "value3", "value3",
        "bad", "bad", "bad")),
        "bad");
    checkValidation_V(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute3", "value3", "value3")));
    checkValidation_RRA(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute3", "value3", null)),
        "attribute3");
    checkValidation_V(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute3", "value3", "value3",
        "attribute4", "value4", "value4",
        "attribute5", "value5", "value5")));
    checkValidation_IAV(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute3", "bad", "bad",
        "attribute4", "value4", "value4",
        "attribute5", "value5", "value5")),
        "attribute3", "bad");
    checkValidation_IAV(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute3", "value3", "value3",
        "attribute4", "bad", "bad",
        "attribute5", "value5", "value5")),
        "attribute4", "bad");
    checkValidation_V(test_element3.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute4", "value4", "value4",
        "attribute5", "value5", "value5")));
    checkValidation_V(test_element3.validateAttributesUpdate(AttributesUpdateImpl.EMPTY_MAP));

    /*
     * Test a pattern containing a single required attribute attribute.
     */
    SchemaPattern test_element4 = test.child("element4");
    checkValidation_IAV(test_element4.validateAttributes(new AttributesImpl(
        "attribute6", "xyz")),
        "attribute6", "xyz");
    checkValidation_IAV(test_element4.validateAttributes(new AttributesImpl(
        "attribute6", "axyz")),
        "attribute6", "axyz");
    checkValidation_IAV(test_element4.validateAttributes(new AttributesImpl(
        "attribute6", "xyzb")),
        "attribute6", "xyzb");
    checkValidation_V(test_element4.validateAttributes(new AttributesImpl(
        "attribute6", "axyzb")));
    checkValidation_IAV(test_element4.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute6", "xyz", "xyz")),
        "attribute6", "xyz");
    checkValidation_IAV(test_element4.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute6", "axyz", "axyz")),
        "attribute6", "axyz");
    checkValidation_IAV(test_element4.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute6", "xyzb", "xyzb")),
        "attribute6", "xyzb");
    checkValidation_V(test_element4.validateAttributesUpdate(new AttributesUpdateImpl(
        "attribute6", "axyzb", "axyzb")));

    /*
     * Test that the "casting" methods of the result objects returned by the
     * validation behave correctly.
     */
    AttributeValidationResult example_V = test_element3.validateAttributes(
        new AttributesImpl(
            "attribute3", "value3"));
    AttributeValidationResult example_ANA = test_element3.validateAttributes(
        new AttributesImpl(
            "attribute3", "value3",
            "bad", "bad"));
    AttributeValidationResult example_IAV = test_element3.validateAttributes(
        new AttributesImpl(
            "attribute3", "bad"));
    AttributeValidationResult example_MRA = test_element3.validateAttributes(
        AttributesImpl.EMPTY_MAP);
    AttributeValidationResult example_RRA = test_element3.validateAttributesUpdate(
        new AttributesUpdateImpl(
            "attribute3", "value3", null));
    assertNull(example_V.asAttributeNotAllowed());
    assertNull(example_V.asInvalidAttributeValue());
    assertNull(example_V.asMissingRequiredAttribute());
    assertNull(example_V.asRemovingRequiredAttribute());
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.impl.AttributesUpdateImpl

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.