use of com.buschmais.jqassistant.core.rule.api.model.Concept in project jqa-core-framework by buschmais.
the class AnalyzerRuleVisitor method visitConcept.
@Override
public boolean visitConcept(Concept concept, Severity effectiveSeverity) throws RuleException {
ConceptDescriptor conceptDescriptor = analyzerContext.getStore().find(ConceptDescriptor.class, concept.getId());
Result.Status status;
if (conceptDescriptor == null || configuration.isExecuteAppliedConcepts()) {
analyzerContext.getLogger().info("Applying concept '" + concept.getId() + "' with severity: '" + concept.getSeverity().getInfo(effectiveSeverity) + "'" + ".");
reportPlugin.beginConcept(concept);
Result<Concept> result = execute(concept, effectiveSeverity);
reportPlugin.setResult(result);
status = result.getStatus();
if (conceptDescriptor == null) {
conceptDescriptor = analyzerContext.getStore().create(ConceptDescriptor.class);
conceptDescriptor.setId(concept.getId());
conceptDescriptor.setStatus(status);
}
reportPlugin.endConcept();
} else {
status = conceptDescriptor.getStatus();
}
return Result.Status.SUCCESS.equals(status);
}
use of com.buschmais.jqassistant.core.rule.api.model.Concept in project jqa-core-framework by buschmais.
the class TransactionalVisitorTest method skipConcept.
@Test
void skipConcept() throws RuleException {
Concept concept = mock(Concept.class);
visitor.skipConcept(concept, MINOR);
verify(delegate).skipConcept(concept, MINOR);
verifySuccessfulTransaction();
}
use of com.buschmais.jqassistant.core.rule.api.model.Concept in project jqa-java-plugin by buschmais.
the class SuppressIT method verifySuppress.
private void verifySuppress(String constraintId, String conceptId, String column) throws RuleException {
scanClasses(Suppress.class);
assertThat(validateConstraint(constraintId).getStatus(), equalTo(SUCCESS));
Result<Concept> suppressClasses = applyConcept(conceptId);
assertThat(suppressClasses.getStatus(), equalTo(SUCCESS));
store.beginTransaction();
assertThat(suppressClasses.getRows().size(), equalTo(1));
Map<String, Object> row = suppressClasses.getRows().get(0);
JavaSuppressDescriptor suppressDescriptor = (JavaSuppressDescriptor) row.get(column);
assertThat(asList(suppressDescriptor.getSuppressIds()), hasItem(constraintId));
store.commitTransaction();
}
use of com.buschmais.jqassistant.core.rule.api.model.Concept in project jqa-core-framework by buschmais.
the class CompositeReportPluginTest method noSelection.
@Test
void noSelection() throws ReportException {
Concept concept = getRule(Concept.class);
Constraint constraint = getRule(Constraint.class);
write(concept, constraint);
verifyInvoked(concept, reportPlugin1, reportPlugin2);
verifyNotInvoked(concept, reportPlugin3, selectableReportPlugin1, selectableReportPlugin2);
verifyInvoked(constraint, reportPlugin1, reportPlugin2);
verifyNotInvoked(constraint, reportPlugin3, selectableReportPlugin1, selectableReportPlugin2);
verifyGroup();
}
use of com.buschmais.jqassistant.core.rule.api.model.Concept in project jqa-core-framework by buschmais.
the class ReportHelperTest method failedConcepts.
@Test
void failedConcepts() {
Result<Concept> infoConceptResult = mockResult("test:infoConcept", Concept.class, Result.Status.FAILURE, Severity.INFO);
Result<Concept> minorConceptResult = mockResult("test:minorConcept", Concept.class, Result.Status.FAILURE, Severity.MINOR);
Result<Concept> majorConceptResult = mockResult("test:majorConcept", Concept.class, Result.Status.FAILURE, Severity.MAJOR);
Map<String, Result<Concept>> conceptResults = new HashMap<>();
conceptResults.put("test:infoConcept", infoConceptResult);
conceptResults.put("test:minorConcept", minorConceptResult);
conceptResults.put("test:majorConcept", majorConceptResult);
when(inMemoryReportWriter.getConceptResults()).thenReturn(conceptResults);
int violations = reportHelper.verifyConceptResults(Severity.MINOR, Severity.MAJOR, inMemoryReportWriter);
assertThat(violations, equalTo(1));
verifyMessages(debugMessages, ReportHelper.CONCEPT_FAILED_HEADER, "Concept: test:infoConcept", "Severity: INFO");
verifyMessages(warnMessages, ReportHelper.CONCEPT_FAILED_HEADER, "Concept: test:minorConcept", "Severity: MINOR");
verifyMessages(errorMessages, ReportHelper.CONCEPT_FAILED_HEADER, "Concept: test:majorConcept", "Severity: MAJOR");
}
Aggregations