AnalyzerRuleVisitor extends AbstractRuleVisitor { @Override public void visitConstraint(Constraint constraint, Severity effectiveSeverity) throws RuleException { analyzerContext.getLogger() .info("Validating constraint '" + constraint.getId() + "' with severity: '" + constraint.getSeverity().getInfo(effectiveSeverity) + "'."); reportPlugin.beginConstraint(constraint); reportPlugin.setResult(execute(constraint, effectiveSeverity)); reportPlugin.endConstraint(); } AnalyzerRuleVisitor(AnalyzerConfiguration configuration, AnalyzerContext analyzerContext, Map<String, String> ruleParameters,
            Map<String, Collection<RuleInterpreterPlugin>> ruleInterpreterPlugins, ReportPlugin reportPlugin); @Override void beforeRules(); @Override void afterRules(); @Override boolean visitConcept(Concept concept, Severity effectiveSeverity); @Override void skipConcept(Concept concept, Severity effectiveSeverity); @Override void visitConstraint(Constraint constraint, Severity effectiveSeverity); @Override void skipConstraint(Constraint constraint, Severity effectiveSeverity); @Override void beforeGroup(Group group, Severity effectiveSeverity); @Override void afterGroup(Group group);  }
@Test public void executeConstraint() throws RuleException { doReturn(Result.Status.FAILURE).when(analyzerContext).verify(eq(constraint), anyList(), anyList()); analyzerRuleVisitor.visitConstraint(constraint, Severity.BLOCKER); ArgumentCaptor<Map> argumentCaptor = ArgumentCaptor.forClass(Map.class); verify(store).executeQuery(eq(statement), argumentCaptor.capture()); Map<String, Object> parameters = argumentCaptor.getValue(); assertThat(parameters.get(PARAMETER_WITHOUT_DEFAULT), equalTo("value")); assertThat(parameters.get(PARAMETER_WITH_DEFAULT), equalTo("defaultValue")); verify(reportWriter).beginConstraint(constraint); ArgumentCaptor<Result> resultCaptor = ArgumentCaptor.forClass(Result.class); verify(reportWriter).setResult(resultCaptor.capture()); Result result = resultCaptor.getValue(); assertThat(result.getStatus(), equalTo(Result.Status.FAILURE)); assertThat(result.getSeverity(), equalTo(Severity.BLOCKER)); verify(reportWriter).endConstraint(); }