public void testContained() throws Exception {
    // test adding/removing/moving

    ICompilationUnit cu = createTestXmlPath();
    JavaResourceType resourceType = buildJavaResourceType(cu);
    JavaResourceField resourceAttribute = getField(resourceType, 0);

    assertEquals(1, resourceAttribute.getAnnotationsSize(ELJaxb.XML_PATH));

    resourceAttribute.addAnnotation(1, ELJaxb.XML_PATH);

    assertEquals(2, resourceAttribute.getAnnotationsSize(ELJaxb.XML_PATH));
    assertSourceContains("@XmlPaths({ @XmlPath, @XmlPath })", cu);

    XmlPathAnnotation annotation1 = getXmlPathAnnotation(resourceAttribute, 0);
    annotation1.setValue("foo");
    XmlPathAnnotation annotation2 = getXmlPathAnnotation(resourceAttribute, 1);
    annotation2.setValue("bar");
    assertSourceContains("@XmlPaths({ @XmlPath(\"foo\"), @XmlPath(\"bar\") })", cu);

    resourceAttribute.moveAnnotation(0, 1, ELJaxb.XML_PATH);
    assertSourceContains("@XmlPaths({ @XmlPath(\"bar\"), @XmlPath(\"foo\") })", cu);

    resourceAttribute.removeAnnotation(0, ELJaxb.XML_PATH);
    assertEquals(1, resourceAttribute.getAnnotationsSize(ELJaxb.XML_PATH));
    assertSourceContains("@XmlPath(\"foo\")", cu);
    assertSourceDoesNotContain("@XmlPaths", cu);
  }
  public void testValue() throws Exception {
    ICompilationUnit cu = createTestXmlPathWithValue();
    JavaResourceType resourceType = buildJavaResourceType(cu);
    JavaResourceField resourceAttribute = getField(resourceType, 0);
    XmlPathAnnotation annotation = getXmlPathAnnotation(resourceAttribute);

    assertEquals("foo", annotation.getValue());
    assertSourceContains("@XmlPath(\"foo\")", cu);

    annotation.setValue("bar");

    assertEquals("bar", annotation.getValue());
    assertSourceContains("@XmlPath(\"bar\")", cu);

    annotation.setValue("");

    assertEquals("", annotation.getValue());
    assertSourceContains("@XmlPath(\"\")", cu);

    annotation.setValue(null);

    assertNull(annotation.getValue());
    assertSourceContains("@XmlPath", cu);
    assertSourceDoesNotContain("@XmlPath(", cu);
  }
  public void testContainedValue() throws Exception {
    // test contained annotation value setting/updating

    ICompilationUnit cu = createTestXmlPaths();
    JavaResourceType resourceType = buildJavaResourceType(cu);
    JavaResourceField resourceAttribute = getField(resourceType, 0);
    XmlPathAnnotation annotation = getXmlPathAnnotation(resourceAttribute);

    assertNull(annotation.getValue());
    assertSourceContains("@XmlPaths({@XmlPath,@XmlPath})", cu);

    annotation.setValue("foo");
    assertEquals("foo", annotation.getValue());
    assertSourceContains("@XmlPaths({@XmlPath(\"foo\"),@XmlPath})", cu);

    annotation.setValue(null);
    assertNull(annotation.getValue());
    assertSourceContains("@XmlPaths({@XmlPath,@XmlPath})", cu);
  }