<?xml version="1.0" encoding="UTF-8"?>
<test-data>
    <code-fragment id="with-all-comments"><![CDATA[
/**
 * Class level comment.
 */
public class Foo {
  /** the bar counter. */
  public int bar;
  /** the test enum. */
  public enum Enum {}
  /**
   * This is the comment for the constructor
   */
  public Foo() {}
  /**
   * This is the comment for the first method
   */
  public void doNothing() {}
  /**
   * This is the comment for the second method
   */
  public void doSomething() {}
}
    ]]></code-fragment>
    <code-fragment id="without-any-comments"><![CDATA[
public class Foo {
  public int bar;
  public enum Enum {}
  public Foo() {}
  public void doNothing() {}
  public void doSomething() {}
}
    ]]></code-fragment>

    <test-code>
        <description>Missing comments - all required (default).</description>
        <expected-problems>6</expected-problems>
        <code-ref id="without-any-comments"/>
    </test-code>

    <test-code>
        <description>All elements have javadoc comments.</description>
        <expected-problems>0</expected-problems>
        <code-ref id="with-all-comments"/>
    </test-code>

    <test-code>
        <description>Missing comments - only class level required.</description>
        <expected-problems>1</expected-problems>
        <rule-property name="headerCommentRequirement">Required</rule-property>
        <rule-property name="fieldCommentRequirement">Ignored</rule-property>
        <rule-property name="publicMethodCommentRequirement">Ignored</rule-property>
        <rule-property name="protectedMethodCommentRequirement">Ignored</rule-property>
        <rule-property name="enumCommentRequirement">Ignored</rule-property>
        <code-ref id="without-any-comments"/>
    </test-code>

    <test-code>
        <description>Too many comments - all comments are unwanted.</description>
        <expected-problems>6</expected-problems>
        <rule-property name="headerCommentRequirement">Unwanted</rule-property>
        <rule-property name="fieldCommentRequirement">Unwanted</rule-property>
        <rule-property name="publicMethodCommentRequirement">Unwanted</rule-property>
        <rule-property name="protectedMethodCommentRequirement">Unwanted</rule-property>
        <rule-property name="enumCommentRequirement">Unwanted</rule-property>
        <code-ref id="with-all-comments"/>
    </test-code>

    <test-code>
        <description>#1115 commentRequiredRule in pmd 5.1 is not working properly</description>
        <expected-problems>2</expected-problems>
        <code><![CDATA[
/**
 * Test class
 */
public class Test {
    public void method1() {
        /**
         * comment here
         */
    }
    
    public void method2() {
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#1115 commentRequiredRule in pmd 5.1 is not working properly - without new lines</description>
        <expected-problems>2</expected-problems>
        <code><![CDATA[
/** Test class */ public class Test { public void method1() { /** comment here */ } public void method2() { } }
        ]]></code>
    </test-code>

    <test-code>
        <description>#1289 CommentRequired not ignored if javadoc {@inheritDoc} anon inner classes</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
/**
 * Comment required test class.
 */
public class CommentRequired {
    /**
     * Creates a new instance of comment required.
     */
    public CommentRequired() {
        Object o = new Object() {
            /**
             * {@inheritDoc}
             */
            public String toString() {
                return "Inner Class";
            }
        };
    }
}
        ]]></code>
    </test-code>
</test-data>
