@Test public void testExcludeVariableViolation() { final VariableViolation doesMatch = mock(VariableViolation.class); when(doesMatch.getVariableName()).thenReturn(StringUtils.swapCase(variableName)); final VariableViolation noMatch = mock(VariableViolation.class); when(noMatch.getVariableName()).thenReturn(StringUtils.reverse(variableName)); assertThat(filter.exclude("a.variable.name", doesMatch)).isTrue(); assertThat(filter.exclude("another.variable.name", 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 VariableViolation) { return variableName.equalsIgnoreCase(((VariableViolation) violation).getVariableName()); } final String internalValue = getInternalValue(violation, "variableName"); return variableName.equalsIgnoreCase(internalValue); }
VariableNameFilter 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 VariableViolation) { return variableName.equalsIgnoreCase(((VariableViolation) violation).getVariableName()); } final String internalValue = getInternalValue(violation, "variableName"); return variableName.equalsIgnoreCase(internalValue); } }
VariableNameFilter 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 VariableViolation) { return variableName.equalsIgnoreCase(((VariableViolation) violation).getVariableName()); } final String internalValue = getInternalValue(violation, "variableName"); return variableName.equalsIgnoreCase(internalValue); } VariableNameFilter(final String variableName); }
VariableNameFilter 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 VariableViolation) { return variableName.equalsIgnoreCase(((VariableViolation) violation).getVariableName()); } final String internalValue = getInternalValue(violation, "variableName"); return variableName.equalsIgnoreCase(internalValue); } VariableNameFilter(final String variableName); @Override boolean exclude(final String scriptName, final Violation violation); @Override String toString(); }
VariableNameFilter 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 VariableViolation) { return variableName.equalsIgnoreCase(((VariableViolation) violation).getVariableName()); } final String internalValue = getInternalValue(violation, "variableName"); return variableName.equalsIgnoreCase(internalValue); } VariableNameFilter(final String variableName); @Override boolean exclude(final String scriptName, final Violation violation); @Override String toString();  }