Search in sources :

Example 31 with AuditEvent

use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.

the class SuppressionFilterTest method testNonExistanceSuppressionFileWithTrueOptional.

@Test
public void testNonExistanceSuppressionFileWithTrueOptional() throws Exception {
    final String fileName = "src/test/resources/com/puppycrawl/tools/checkstyle/filters/" + "non_existance_suppresion_file.xml";
    final boolean optional = true;
    final SuppressionFilter filter = createSupressionFilter(fileName, optional);
    final AuditEvent ev = new AuditEvent(this, "AnyFile.java", null);
    assertTrue(filter.accept(ev));
}
Also used : AuditEvent(com.puppycrawl.tools.checkstyle.api.AuditEvent) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 32 with AuditEvent

use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.

the class SuppressElementTest method testDecideByFileNameAndModuleMatchingModuleNotEqual.

@Test
public void testDecideByFileNameAndModuleMatchingModuleNotEqual() {
    final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, "TheirModule", getClass(), null);
    final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
    filter.setModuleId("MyModule");
    assertTrue(filter.accept(ev));
}
Also used : AuditEvent(com.puppycrawl.tools.checkstyle.api.AuditEvent) LocalizedMessage(com.puppycrawl.tools.checkstyle.api.LocalizedMessage) Test(org.junit.Test)

Example 33 with AuditEvent

use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.

the class SuppressElementTest method testDecideDefault.

@Test
public void testDecideDefault() {
    final AuditEvent ev = new AuditEvent(this, "Test.java");
    assertTrue(ev.getFileName(), filter.accept(ev));
}
Also used : AuditEvent(com.puppycrawl.tools.checkstyle.api.AuditEvent) Test(org.junit.Test)

Example 34 with AuditEvent

use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.

the class SuppressElementTest method testDecideByColumn.

@Test
public void testDecideByColumn() {
    final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
    final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
    //deny because there are matches on file name, check name, and column
    filter.setColumns("1-10");
    assertFalse("In range 1-10", filter.accept(ev));
    filter.setColumns("1-9, 11");
    assertTrue("Not in 1-9, 1)", filter.accept(ev));
}
Also used : AuditEvent(com.puppycrawl.tools.checkstyle.api.AuditEvent) LocalizedMessage(com.puppycrawl.tools.checkstyle.api.LocalizedMessage) Test(org.junit.Test)

Example 35 with AuditEvent

use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.

the class SuppressElementTest method testDecideByFileNameAndModuleMatchingCheckRegExpNotMatch.

@Test
public void testDecideByFileNameAndModuleMatchingCheckRegExpNotMatch() {
    final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
    final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
    filter.setChecks("NON_EXISTING_CHECK");
    assertTrue(filter.accept(ev));
}
Also used : AuditEvent(com.puppycrawl.tools.checkstyle.api.AuditEvent) LocalizedMessage(com.puppycrawl.tools.checkstyle.api.LocalizedMessage) Test(org.junit.Test)

Aggregations

AuditEvent (com.puppycrawl.tools.checkstyle.api.AuditEvent)47 Test (org.junit.Test)38 LocalizedMessage (com.puppycrawl.tools.checkstyle.api.LocalizedMessage)24 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 SeverityLevel (com.puppycrawl.tools.checkstyle.api.SeverityLevel)4 ArrayList (java.util.ArrayList)4 AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)3 Checker (com.puppycrawl.tools.checkstyle.Checker)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 Field (java.lang.reflect.Field)2 CheckstyleCheckerListener (org.apache.maven.plugins.checkstyle.exec.CheckstyleCheckerListener)2 CheckstyleResults (org.apache.maven.plugins.checkstyle.exec.CheckstyleResults)2 Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 List (java.util.List)1 SinkEventAttributeSet (org.apache.maven.doxia.sink.SinkEventAttributeSet)1