<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">

    <test-code>
        <description>method names should start with lowercase character</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    void Bar() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>method names should not contain underscores</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar_foo() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>all is well</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void foo() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#1343 MethodNamingConventions for overridden methods</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class MethodNamingConventions implements SomeInterface {
    public override void _foo() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#25 Method rules should ignore Property Getter/Setter</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public Integer property { get; private set; }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#26 Constructors should not trigger "Method names should not start with capital letters" issue</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public Foo() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>all is well</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    @isTest
    public static void testMethod1() { } // "testmethod" is a keyword in apex
    public static void staticMethod() { }
    public void instanceMethod() { }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>default is camel case</description>
        <expected-problems>3</expected-problems>
        <expected-messages>
            <message>The test method name 'TEST_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
            <message>The static method name 'STATIC_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
            <message>The instance method name 'INSTANCE_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
        </expected-messages>
        <code><![CDATA[
public class Foo {
    @isTest
    public static void TEST_METHOD() { }
    public static void STATIC_METHOD() { }
    public void INSTANCE_METHOD() { }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>ignores overrides</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public override Integer BAR() { }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>ignores properties</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public Integer BAR { get; set; }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>ignores constructors</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class FOO {
    public FOO() { }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>ignores enum methods</description>
        <rule-property name="instancePattern">Z</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    enum Bar {
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>custom test method pattern</description>
        <rule-property name="testPattern">[a-zA-Z0-9_]+</rule-property>
        <expected-problems>2</expected-problems>
        <expected-messages>
            <message>The static method name 'STATIC_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
            <message>The instance method name 'INSTANCE_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
        </expected-messages>
        <code><![CDATA[
public class Foo {
    @isTest
    public static void TEST_METHOD() { }
    public static void STATIC_METHOD() { }
    public void INSTANCE_METHOD() { }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>custom static method pattern</description>
        <rule-property name="staticPattern">[a-zA-Z0-9_]+</rule-property>
        <expected-problems>2</expected-problems>
        <expected-messages>
            <message>The test method name 'TEST_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
            <message>The instance method name 'INSTANCE_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
        </expected-messages>
        <code><![CDATA[
public class Foo {
    @isTest
    public static void TEST_METHOD() { }
    public static void STATIC_METHOD() { }
    public void INSTANCE_METHOD() { }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>custom instance method pattern</description>
        <rule-property name="instancePattern">[a-zA-Z0-9_]+</rule-property>
        <expected-problems>2</expected-problems>
        <expected-messages>
            <message>The test method name 'TEST_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
            <message>The static method name 'STATIC_METHOD' doesn't match '[a-z][a-zA-Z0-9]*'</message>
        </expected-messages>
        <code><![CDATA[
public class Foo {
    @isTest
    public static void TEST_METHOD() { }
    public static void STATIC_METHOD() { }
    public void INSTANCE_METHOD() { }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>static initializer</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    static {
        String s = 'a';
    }
}
]]></code>
    </test-code>
</test-data>
