use of com.buschmais.jqassistant.core.report.api.model.Result in project jqa-core-framework by buschmais.
the class ReportHelperTest method validatedConstraint.
@Test
void validatedConstraint() {
Result<Constraint> constraintResult = mockResult("test:concept", Constraint.class, Result.Status.SUCCESS, Severity.MAJOR);
Map<String, Result<Constraint>> constraintResults = new HashMap<>();
constraintResults.put("test:concept", constraintResult);
when(inMemoryReportWriter.getConstraintResults()).thenReturn(constraintResults);
int violations = reportHelper.verifyConstraintResults(Severity.MINOR, Severity.MINOR, inMemoryReportWriter);
assertThat(violations, equalTo(0));
assertThat(warnMessages.size(), equalTo(0));
assertThat(debugMessages.size(), equalTo(0));
assertThat(errorMessages.size(), equalTo(0));
}
use of com.buschmais.jqassistant.core.report.api.model.Result in project jqa-core-framework by buschmais.
the class ReportHelperTest method failedConceptsWithOverriddenSeverity.
@Test
void failedConceptsWithOverriddenSeverity() {
Result<Concept> infoConceptResult = mockResult("test:infoConcept", Concept.class, Result.Status.FAILURE, Severity.INFO, Severity.MINOR);
Result<Concept> minorConceptResult = mockResult("test:minorConcept", Concept.class, Result.Status.FAILURE, Severity.MINOR, Severity.MAJOR);
Result<Concept> majorConceptResult = mockResult("test:majorConcept", Concept.class, Result.Status.FAILURE, Severity.MAJOR, Severity.CRITICAL);
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.MAJOR, Severity.CRITICAL, inMemoryReportWriter);
assertThat(violations, equalTo(1));
verifyMessages(debugMessages, ReportHelper.CONCEPT_FAILED_HEADER, "Concept: test:infoConcept", "Severity: MINOR (from INFO)");
verifyMessages(warnMessages, ReportHelper.CONCEPT_FAILED_HEADER, "Concept: test:minorConcept", "Severity: MAJOR (from MINOR)");
verifyMessages(errorMessages, ReportHelper.CONCEPT_FAILED_HEADER, "Concept: test:majorConcept", "Severity: CRITICAL (from MAJOR)");
}
use of com.buschmais.jqassistant.core.report.api.model.Result in project jqa-core-framework by buschmais.
the class ReportHelperTest method failedConstraints.
@Test
void failedConstraints() {
Map<String, Object> infoRow = new HashMap<>();
infoRow.put("InfoElement", "InfoValue");
Result<Constraint> infoConstraintResult = mockResult("test:infoConstraint", Constraint.class, Result.Status.FAILURE, Severity.INFO, singletonList(infoRow));
Map<String, Object> minorRow = new HashMap<>();
minorRow.put("MinorElement", "MinorValue");
Result<Constraint> minorConstraintResult = mockResult("test:minorConstraint", Constraint.class, Result.Status.FAILURE, Severity.MINOR, singletonList(minorRow));
Map<String, Object> majorRow = new HashMap<>();
majorRow.put("MajorElement", "MajorValue");
Result<Constraint> majorConstraintResult = mockResult("test:majorConstraint", Constraint.class, Result.Status.FAILURE, Severity.MAJOR, singletonList(majorRow));
Map<String, Result<Constraint>> constraintResults = new HashMap<>();
constraintResults.put("test:infoConstraint", infoConstraintResult);
constraintResults.put("test:minorConstraint", minorConstraintResult);
constraintResults.put("test:majorConstraint", majorConstraintResult);
when(inMemoryReportWriter.getConstraintResults()).thenReturn(constraintResults);
int violations = reportHelper.verifyConstraintResults(Severity.MINOR, Severity.MAJOR, inMemoryReportWriter);
assertThat(violations, equalTo(1));
verifyMessages(debugMessages, ReportHelper.CONSTRAINT_VIOLATION_HEADER, "Constraint: test:infoConstraint", "Severity: INFO", "InfoElement=InfoValue");
verifyMessages(warnMessages, ReportHelper.CONSTRAINT_VIOLATION_HEADER, "Constraint: test:minorConstraint", "Severity: MINOR", "MinorElement=MinorValue");
verifyMessages(errorMessages, ReportHelper.CONSTRAINT_VIOLATION_HEADER, "Constraint: test:majorConstraint", "Severity: MAJOR", "MajorElement=MajorValue");
}
use of com.buschmais.jqassistant.core.report.api.model.Result in project jqa-core-framework by buschmais.
the class ReportHelperTest method successfulConcept.
@Test
void successfulConcept() {
Result<Concept> conceptResult = mockResult("test:concept", Concept.class, Result.Status.SUCCESS, Severity.MAJOR);
Map<String, Result<Concept>> conceptResults = new HashMap<>();
conceptResults.put("test:concept", conceptResult);
when(inMemoryReportWriter.getConceptResults()).thenReturn(conceptResults);
int violations = reportHelper.verifyConceptResults(Severity.MINOR, Severity.MAJOR, inMemoryReportWriter);
assertThat(violations, equalTo(0));
assertThat(warnMessages.size(), equalTo(0));
assertThat(debugMessages.size(), equalTo(0));
assertThat(errorMessages.size(), equalTo(0));
}
use of com.buschmais.jqassistant.core.report.api.model.Result 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);
}
Aggregations