### Question:
SubroutineNameFilter extends AbstractPropertyReflectingFilter { @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."); } if (violation instanceof SubroutineViolation) { return subroutineName.equalsIgnoreCase(((SubroutineViolation) violation).getSubroutineName()); } final String internalValue = getInternalValue(violation, "subroutineName"); return subroutineName.equalsIgnoreCase(internalValue); } SubroutineNameFilter(final String subroutineName); @Override boolean exclude(final String scriptName, final Violation violation); @Override String toString();  }### Answer:
@Test public void testExcludeSubroutineViolation() { final SubroutineViolation doesMatch = mock(SubroutineViolation.class); when(doesMatch.getSubroutineName()).thenReturn(StringUtils.swapCase(subroutineName)); final SubroutineViolation noMatch = mock(SubroutineViolation.class); when(noMatch.getSubroutineName()).thenReturn(StringUtils.reverse(subroutineName)); assertThat(filter.exclude("a.script", doesMatch)).isTrue(); assertThat(filter.exclude("another.script", noMatch)).isFalse(); }
@Test public void testExcludeInternalValue() { final List<String> internalValues = new ArrayList<String>(3); internalValues.add(StringUtils.swapCase(subroutineName)); internalValues.add(StringUtils.reverse(subroutineName)); internalValues.add(null); final Violation violation = mock(Violation.class); final SubroutineNameFilter toTest = new SubroutineNameFilter(subroutineName) { @SuppressWarnings("unchecked") @Override protected String getInternalValue(final Violation violation, final String propertyName) { return internalValues.remove(0); } }; assertThat(toTest.exclude("a.script.name", violation)).isTrue(); assertThat(toTest.exclude("another.script.name", violation)).isFalse(); assertThat(toTest.exclude("yet.another.", violation)).isFalse(); }