<?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>Failure case: Empty Statement Block</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public void foo() {
    }

    public abstract void bar() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>Success case: Empty Statement Block</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public void foo() {
        system.debug(1);
    }
    public abstract void bar() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#760 - false positive on non existing else block</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public void foo() {
        if (something) {
            system.debug(1);
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#760 - is reported on existing else block</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public void foo() {
        if (something) {
            system.debug(1);
        } else {
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#3568 - Verify use of reportEmptyPrivateNoArgConstructor, negative test unspecified/default</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Singleton {
    private Singleton() {
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>#3568 - Verify use of reportEmptyPrivateNoArgConstructor, negative test specified</description>
        <rule-property name="reportEmptyPrivateNoArgConstructor">true</rule-property>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Singleton {
    private Singleton() {
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>#3568 - Verify use of reportEmptyPrivateNoArgConstructor, positive test</description>
        <rule-property name="reportEmptyPrivateNoArgConstructor">false</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Singleton {
    private Singleton() {
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>#3568 - Verify use of reportEmptyVirtualMethod, negative test unspecified/default</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public abstract class AbstractBaseClass {
    public virtual void overrideMe() {
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>#3568 - Verify use of reportEmptyVirtualMethod, negative test specified</description>
        <rule-property name="reportEmptyVirtualMethod">true</rule-property>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public abstract class AbstractBaseClass {
    public virtual void overrideMe() {
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>#3568 - Verify use of reportEmptyVirtualMethod, positive test</description>
        <rule-property name="reportEmptyVirtualMethod">false</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public abstract class AbstractBaseClass {
    public virtual void overrideMe() {
    }
}
]]></code>
    </test-code>


    <test-code>
        <description>Empty catch blocks should not be reported</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public void myMethod() {
        try {
            println('a');
        } catch (Exception e) {
            // empty - this is a EmptyCatchBlock violation and not a EmptyStatementBlock!
        }
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>EmptyStatementBlock in trigger (#5138)</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>18</expected-linenumbers>
        <code><![CDATA[
// https://github.com/SalesforceLabs/chatter-delete-blocker/blob/master/src/triggers/DisableFeedPostDeletes.trigger
/**
 * Author: Marcus Ericsson - mericsson@salesforce.com
 */
trigger DisableFeedPostDeletes on FeedItem (before delete)
{
    if (!DisableChatterDeleteDelegate.allowDelete()) {
        for(FeedItem f : Trigger.old){
            if (((String)f.parentId).startsWith('00Q') && f.type == 'TrackedChange') {
                // ok to ignore
            }
            else {
                f.addError('Your administrator has disabled feed post and comment deletions.');
            }
        }
    }

    public void setBar(Integer bar) {
         // empty
    }
}
]]></code>
    </test-code>
</test-data>
