use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingMessageNull.
@Test
public void testDecideByFileNameAndModuleMatchingMessageNull() {
final AuditEvent ev = new AuditEvent(this, "ATest.java", null);
assertTrue(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideByFileNameAndModuleMatchingCheckRegExpMatch.
@Test
public void testDecideByFileNameAndModuleMatchingCheckRegExpMatch() {
final LocalizedMessage message = new LocalizedMessage(10, 10, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
filter.setChecks(getClass().getCanonicalName());
assertFalse(filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class SuppressElementTest method testDecideLocalizedMessage.
@Test
public void testDecideLocalizedMessage() {
final LocalizedMessage message = new LocalizedMessage(0, 0, "", "", null, null, getClass(), null);
final AuditEvent ev = new AuditEvent(this, "ATest.java", message);
//deny because there are matches on file and check names
assertFalse("Names match", filter.accept(ev));
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle-idea by jshiell.
the class CheckStyleAuditListenerTest method testWithoutLocalizedMessage.
@Test
public void testWithoutLocalizedMessage() {
final CheckStyleAuditListener underTest = new CheckStyleAuditListener(Collections.emptyMap(), false, 2, Optional.empty(), Collections.emptyList());
try {
// quite unlikely to happen in real life
underTest.addError(new AuditEvent("source", "filename.java"));
Assert.fail("expected exception was not thrown");
} catch (NullPointerException e) {
// expected
}
}
use of com.puppycrawl.tools.checkstyle.api.AuditEvent in project checkstyle by checkstyle.
the class XMLLogger method writeFileMessages.
/**
* Prints the file section with all file errors and exceptions.
*
* @param fileName The file name, as should be printed in the opening file tag.
* @param messages The file messages.
*/
private void writeFileMessages(String fileName, FileMessages messages) {
writeFileOpeningTag(fileName);
if (messages != null) {
for (AuditEvent errorEvent : messages.getErrors()) {
writeFileError(errorEvent);
}
for (Throwable exception : messages.getExceptions()) {
writeException(exception);
}
}
writeFileClosingTag();
}
Aggregations