Added test and fixed old.
@@ -31,7 +31,27 @@ public class WarningsFilterTest {
WarningsFilter filter = new WarningsFilter();
// exclude warnings with this warning message from the report
final String excludeMessage = "Javadoc: Missing tag for parameter arg1";
- warnings = filter.apply(warnings, null, null, excludeMessage, new NullLogger());
+ warnings = filter.apply(warnings, null, null, excludeMessage, null, new NullLogger());
+
+ assertFalse(warnings.contains(w1));
+ assertTrue(warnings.contains(w2));
+ }
+
+ /**
+ * Tests the exclusion of certain warning messages from the report (based on category).
+ */
+ @Test
+ public void testMessagesPattern() {
+ Warning w1 = new Warning("dummyFile.java", 0, "warningType", "-W#pragma-messages", "Warning. But ok.", Priority.LOW);
+ Warning w2 = new Warning("dummyFile.java", 0, "warningType", "-WWhatever", "Warning. Not ok!", Priority.LOW);
+ Collection<FileAnnotation> warnings = new LinkedList<FileAnnotation>();
+ warnings.add(w1);
+ warnings.add(w2);
+
+ WarningsFilter filter = new WarningsFilter();
+ // exclude warnings with this warning message from the report
+ final String excludeCategory = ".*pragma-messages.*";
+ warnings = filter.apply(warnings, null, null, null, excludeCategory, new NullLogger());
assertFalse(warnings.contains(w1));
assertTrue(warnings.contains(w2));
@@ -40,5 +60,6 @@ public class WarningsFilterTest {
private Warning createDummyWarning(final String message) {
return new Warning("dummyFile.java", 0, "warningType", "warningCategory", message, Priority.LOW);
}
+
}
