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