<?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 with toUpperCase().equals()</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    private boolean baz(String buz) {
        return buz.toUpperCase().equals("foo");
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>failure case with toLowerCase().equals()</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    private boolean baz(String buz) {
        return buz.toLowerCase().equals("foo");
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>failure case with toUpperCase().equalsIgnoreCase()</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    private boolean baz(String buz) {
        return buz.toUpperCase().equalsIgnoreCase("foo");
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>don't flag toUpperCase() invocations with Locale args</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    private boolean baz(String buz) {
        return buz.toUpperCase(locale).equals("foo");
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>failure case with toLowerCase().equals()</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public Object visit(Foo node, Object data) {
        Foo cl = node.getFirstParentOfType(Foo.class);
        if (cl != null && node.getVariableName().toLowerCase().equals(cl.getImage().toLowerCase())) {
            addViolation(data, node);
        }
        return data;
    }

    public Foo getFirstParentOfType(Class<?> clazz) { return null; }
    public String getVariableName() { return null; }
    public String getImage() { return null; }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#2531 foo.equals(bar.toLowerCase()) false negative</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public void bar(String s) {
        if ("test".equals(s.toLowerCase())) {
            System.out.println("Done");
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>NullPointerException if in constructor test</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Person {
    public Person(String name) { }
    public void printData() { }

    public static void bar(String s) {
        Person p = new Person(s.toUpperCase());
        p.printData();
    }
}
        ]]></code>
    </test-code>
</test-data>

