
package org.aludratest.codecheck.rule.pmd.testcase;

import net.sourceforge.pmd.Report;

import org.aludratest.codecheck.rule.pmd.AbstractPmdTestCase;
import org.junit.Test;
import org.test.testclasses.testcase.InvalidTestCaseClass;
import org.test.testclasses.testcase.ValidTestCaseClass;

@SuppressWarnings("javadoc")
public class TestCaseClassNamingRuleTest extends AbstractPmdTestCase {

    @Test
    public void testInvalidClass() {
        TestCaseClassNamingRule rule = new TestCaseClassNamingRule();
        rule.setProperty(rule.regexProperty, "ValidTestCaseClass");
        rule.setProperty(rule.messageProperty, "Class name not OK");
        Report report = runPmdTest(InvalidTestCaseClass.class, rule);
        assertReportViolations(report, 1);
        assertReportViolationMessageMatches(report, 0, "Class name not OK");
    }

    @Test
    public void testValidClass() {
        TestCaseClassNamingRule rule = new TestCaseClassNamingRule();
        rule.setProperty(rule.regexProperty, "ValidTestCaseClass");
        Report report = runPmdTest(ValidTestCaseClass.class, rule);
        assertReportViolations(report, 0);
    }

}
