### Question:
ViolationIdFilter implements ViolationFilter { @Override public boolean exclude(final String scriptName, final Violation violation) { if (scriptName == null) { throw new IllegalArgumentException("Script name cannot be null."); } if (violation == null) { throw new IllegalArgumentException("Violation cannot be null."); } return violationId.equals(violation.getViolationId()); } ViolationIdFilter(final ViolationId violationId); @Override boolean exclude(final String scriptName, final Violation violation); @Override String toString();  }### Answer:
@Test public void testExclude() { when(violation.getViolationId()).thenReturn(violationId); assertThat(filter.exclude("script.name", violation)).isTrue(); }
@Test public void testExcludeNotEqual() { final ViolationId otherId = mock(ViolationId.class); when(violation.getViolationId()).thenReturn(otherId); assertThat(filter.exclude("some.script.name", violation)).isFalse(); }
@Test public void testExcludeNullScriptName() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { filter.exclude(null, violation); }); assertThat(e.getMessage()).isEqualTo("Script name cannot be null."); }
@Test public void testExcludeNullViolation() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { filter.exclude("script.name", null); }); assertThat(e.getMessage()).isEqualTo("Violation cannot be null."); }