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

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


        token(RichTextTokenizer.Type.TEXT, "o"),
        token(RichTextTokenizer.Type.STYLE_FONT_WEIGHT_END));
  }

  public void testListComplex() {
    Attributes listAttribute = new AttributesImpl(Collections.singletonMap("t", "li"));
    verifyTokens(tokenize("<ol><li>fo</li></ol><p>hello</p>"),
        token(RichTextTokenizer.Type.ORDERED_LIST_START),
        token(RichTextTokenizer.Type.LIST_ITEM),
        token(RichTextTokenizer.Type.TEXT, "fo"),
        token(RichTextTokenizer.Type.ORDERED_LIST_END),
View Full Code Here


    /*
     * Test a pattern containing a single non-required attribute whose only
     * allowed value is a fixed string.
     */
    SchemaPattern test_element1 = test.child("element1");
    checkValidation_ANA(test_element1.validateAttributes(new AttributesImpl(
        "bad", "value1")),
        "bad");
    checkValidation_IAV(test_element1.validateAttributes(new AttributesImpl(
        "attribute1", "bad")),
        "attribute1", "bad");
    checkValidation_V(test_element1.validateAttributes(new AttributesImpl(
        "attribute1", "value1")));
    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(
View Full Code Here

  /**
   * Tests a schema featuring top-level optional attributes.
   */
  public void testGoodSchema5() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good5.schema");
    checkValidation_ANA(test.validateAttributes(new AttributesImpl(
        "bad", "value1")),
        "bad");
    checkValidation_ANA(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "bad", "bad")),
        "bad");
    checkValidation_V(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1")));
    checkValidation_V(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute2", "abbbc",
        "attribute3", "axyzb")));
    checkValidation_IAV(test.validateAttributes(new AttributesImpl(
        "attribute1", "bad",
        "attribute2", "abbbc",
        "attribute3", "axyzb")),
        "attribute1", "bad");
    checkValidation_V(test.validateAttributes(AttributesImpl.EMPTY_MAP));
View Full Code Here

  /**
   * Tests a schema featuring top-level attributes, including a required attribute.
   */
  public void testGoodSchema6() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good6.schema");
    checkValidation_MRA(test.validateAttributes(new AttributesImpl(
        "bad", "value1")),
        "attribute1");
    checkValidation_ANA(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "bad", "bad")),
        "bad");
    checkValidation_V(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1")));
    checkValidation_V(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute2", "abbbc",
        "attribute3", "axyzb")));
    checkValidation_IAV(test.validateAttributes(new AttributesImpl(
        "attribute1", "bad",
        "attribute2", "abbbc",
        "attribute3", "axyzb")),
        "attribute1", "bad");
    checkValidation_IAV(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute2", "bad",
        "attribute3", "axyzb")),
        "attribute2", "bad");
    checkValidation_MRA(test.validateAttributes(new AttributesImpl(
        "attribute2", "abbbc",
        "attribute3", "axyzb")),
        "attribute1");
    checkValidation_MRA(test.validateAttributes(AttributesImpl.EMPTY_MAP),
        "attribute1");
View Full Code Here

  /**
   * Tests a schema featuring references.
   */
  public void testGoodSchema9() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good9.schema");
    checkValidation_V(test.validateAttributes(new AttributesImpl("attribute1", "value1")));
    checkValidation_V(test.validateAttributes(new AttributesImpl("attribute2", "value2")));
    checkValidation_ANA(test.validateAttributes(new AttributesImpl("bad", "bad")), "bad");
    SchemaPattern test_element1 = test.child("element1");
    assertNull(test_element1.child("bad"));
    assertNotNull(test_element1.child("element4"));
    SchemaPattern test_element2 = test.child("element2");
    assertNull(test_element2.child("bad"));
View Full Code Here

   * Tests a schema featuring a nested reference.
   */
  public void testGoodSchema10() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good10.schema");
    SchemaPattern test_element0 = test.child("element0");
    checkValidation_V(test_element0.validateAttributes(new AttributesImpl("attribute1", "value1")));
    checkValidation_V(test_element0.validateAttributes(new AttributesImpl("attribute2", "value2")));
    checkValidation_ANA(test_element0.validateAttributes(new AttributesImpl("bad", "bad")), "bad");
    SchemaPattern test_element0_element1 = test_element0.child("element1");
    assertNull(test_element0_element1.child("bad"));
    assertNotNull(test_element0_element1.child("element4"));
    SchemaPattern test_element0_element2 = test_element0.child("element2");
    assertNull(test_element0_element2.child("bad"));
View Full Code Here

  /**
   * Tests a schema featuring references involving required attributes.
   */
  public void testGoodSchema11() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good11.schema");
    checkValidation_V(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute2", "value2",
        "attribute3", "value3",
        "attribute4", "value4")));
    checkValidation_V(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute3", "value3",
        "attribute4", "value4")));
    checkValidation_V(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute2", "value2",
        "attribute3", "value3")));
    checkValidation_MRA(test.validateAttributes(new AttributesImpl(
        "attribute2", "value2",
        "attribute3", "value3",
        "attribute4", "value4")),
        "attribute1");
    checkValidation_MRA(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute2", "value2",
        "attribute4", "value4")),
        "attribute3");
    checkValidation_ANA(test.validateAttributes(new AttributesImpl(
        "attribute1", "value1",
        "attribute2", "value2",
        "attribute3", "value3",
        "attribute4", "value4",
        "bad", "bad")),
View Full Code Here

  /**
   * Tests a schema featuring references with double indirection.
   */
  public void testGoodSchema12() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good12.schema");
    checkValidation_V(test.validateAttributes(new AttributesImpl("attribute1", "value1")));
    checkValidation_V(test.validateAttributes(new AttributesImpl("attribute2", "value2")));
    checkValidation_V(test.validateAttributes(new AttributesImpl("attribute3", "value3")));
    checkValidation_ANA(test.validateAttributes(new AttributesImpl("bad", "bad")), "bad");
    SchemaPattern test_element1 = test.child("element1");
    assertNull(test_element1.child("bad"));
    assertNotNull(test_element1.child("element4"));
    SchemaPattern test_element2 = test.child("element2");
    assertNull(test_element2.child("bad"));
View Full Code Here

   * Tests a schema featuring a recursive reference.
   */
  public void testGoodSchema13() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good13.schema");
    for (int i = 0; i < 16; ++i) {
      checkValidation_V(test.validateAttributes(new AttributesImpl("attribute1", "value1")));
      checkValidation_ANA(test.validateAttributes(new AttributesImpl("bad", "bad")), "bad");
      test = test.child("element1");
    }
  }
View Full Code Here

    String[] values = { "value1", "value2", "value3" };
    for (int i = 0; i < 16; ++i) {
      int k0 = i % 3;
      int k1 = (i + 1) % 3;
      int k2 = (i + 2) % 3;
      checkValidation_V(pattern.validateAttributes(new AttributesImpl(attributes[k0], values[k0])));
      checkValidation_ANA(
          pattern.validateAttributes(new AttributesImpl(attributes[k1], values[k1])),
          attributes[k1]);
      checkValidation_ANA(
          pattern.validateAttributes(new AttributesImpl(attributes[k2], values[k2])),
          attributes[k2]);
      pattern = pattern.child(elements[i % 3]);
    }
  }
View Full Code Here

TOP

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

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.