<?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>condition ? true : foo</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public boolean test(boolean condition) {
        return condition ? true : something();
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>condition ? false : foo</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public void test(boolean condition) {
        final boolean value = condition ? false : something();
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>condition ? foo : true</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public boolean test(boolean condition) {
        return condition ? something() : true;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>condition ? foo : false</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public void test(boolean condition) {
        final boolean otherValue = condition ? something() : false;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#3603 condition ? true : false</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public boolean test(boolean condition) {
        return condition ? true : false;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#1424 False positive with ternary operator</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class SimplifiedTernary {
    private SimplifiedTernary doStuff(SimplifiedTernary someValue, boolean condition) {
        return condition ? something(true) : someValue;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#232 False positive with ternary operator using nullables</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class SimplifiedTernary {
    public Boolean getHasCustomName(boolean mHasCustomName) {
        return mHasCustomName ? true : null;
    }
}
        ]]></code>
    </test-code>
</test-data>
