@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(); }
@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 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 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); }
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(); }
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();  }