<?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</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>4</expected-linenumbers>
        <code><![CDATA[
import junit.framework.TestCase;
public class Foo extends TestCase {
    void bar() {
        assertTrue(true);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>variations</description>
        <expected-problems>4</expected-problems>
        <expected-linenumbers>4,5,6,7</expected-linenumbers>
        <code><![CDATA[
import junit.framework.TestCase;
public class Foo extends TestCase {
    void bar() {
        assertTrue(true);
        assertTrue(false);
        assertFalse(true);
        assertFalse(false);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>nested boolean literal</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import junit.framework.TestCase;
public class Foo extends TestCase {
    void bar() {
        assertTrue(foobar(fiddle, true));
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>asserting true a ! (see also #3087)</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>14</expected-linenumbers>
        <code><![CDATA[
import junit.framework.TestCase;
public class Foo extends TestCase {
    private boolean flag;
    private Foo field;
    void bar(boolean foo) {
        assertTrue(!foo);   // not relevant for this rule, but SimplifiableTestAssertion
        assertFalse(foo);   // that's ok

        assertTrue(!this.flag); // not relevant for this rule, but SimplifiableTestAssertion
        assertFalse(this.flag);
        assertTrue(!field.flag);
        assertFalse(field.flag); // not relevant for this rule, but SimplifiableTestAssertion

        assertTrue(!false); // unnecessary
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>asserting false a ! (see also #3087)</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>14</expected-linenumbers>
        <code><![CDATA[
import junit.framework.TestCase;
public class Foo extends TestCase {
    private boolean flag;
    private Foo field;
    void bar(boolean foo) {
        assertFalse(!foo);  // not relevant for this rule, but SimplifiableTestAssertion
        assertTrue(foo);    // that's ok

        assertFalse(!this.flag); // not relevant for this rule, but SimplifiableTestAssertion
        assertTrue(this.flag);
        assertFalse(!field.flag); // not relevant for this rule, but SimplifiableTestAssertion
        assertTrue(field.flag);

        assertFalse(!true); // unnecessary
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>buz</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import junit.framework.TestCase;
public class Foo extends TestCase {
    void bar(String s) {
        assertTrue(!s.contains(new Foo(s, s.toString())));
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>not a JUnit test - failure case</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar() {
        assertTrue(true);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>JUnit 4 - failure case</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>5</expected-linenumbers>
        <code><![CDATA[
import org.junit.Test;
public class Foo {
    @Test
    void bar() {
        assertTrue(true);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>JUnit 5 - failure case - @Test</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>6</expected-linenumbers>
        <code><![CDATA[
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
    @Test
    void bar() {
        assertTrue(true);
    }
}
        ]]></code>
    </test-code>
</test-data>
