use of com.buschmais.jqassistant.core.rule.api.model.Concept 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.rule.api.model.Concept 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.rule.api.model.Concept in project jqa-core-framework by buschmais.
the class XmlReportTestHelper method createXmlReport.
/**
* Creates a test report.
*
* @return The test report.
* @throws ReportException
* If the test fails.
*/
public File createXmlReport() throws ReportException {
xmlReportWriter.begin();
Concept concept = Concept.builder().id("my:concept").description("My concept description").severity(Severity.MAJOR).executable(new CypherExecutable("match...")).verification(ROW_COUNT_VERIFICATION).report(Report.builder().primaryColumn("c2").build()).build();
Map<String, Severity> concepts = new HashMap<>();
concepts.put("my:concept", Severity.INFO);
Group group = Group.builder().id("default").description("My group").concepts(concepts).build();
xmlReportWriter.beginGroup(group);
xmlReportWriter.beginConcept(concept);
List<Map<String, Object>> rows = new ArrayList<>();
rows.add(createRow());
Result<Concept> result = Result.<Concept>builder().rule(concept).status(Result.Status.SUCCESS).severity(Severity.CRITICAL).columnNames(Arrays.asList(C1, C2)).rows(rows).build();
xmlReportWriter.setResult(result);
xmlReportWriter.endConcept();
xmlReportWriter.endGroup();
xmlReportWriter.end();
return xmlReportWriter.getXmlReportFile();
}
use of com.buschmais.jqassistant.core.rule.api.model.Concept in project jqa-core-framework by buschmais.
the class CompositeReportPluginTest method selectMultiplePlugins.
@Test
void selectMultiplePlugins() throws ReportException {
Concept concept = getRule(Concept.class, "selectablePlugin1", "selectablePlugin2");
Constraint constraint = getRule(Constraint.class, "selectablePlugin1", "selectablePlugin2");
write(concept, constraint);
verifyInvoked(concept, reportPlugin1, reportPlugin2, selectableReportPlugin1, selectableReportPlugin2);
verifyInvoked(constraint, reportPlugin1, reportPlugin2, selectableReportPlugin1, selectableReportPlugin2);
verifyNotInvoked(concept, reportPlugin3);
verifyNotInvoked(constraint, reportPlugin3);
verifyGroup();
}
use of com.buschmais.jqassistant.core.rule.api.model.Concept in project jqa-core-framework by buschmais.
the class CompositeReportPluginTest method selectOneWriter.
@Test
void selectOneWriter() throws ReportException {
Concept concept = getRule(Concept.class, "selectablePlugin1");
Constraint constraint = getRule(Constraint.class, "selectablePlugin1");
write(concept, constraint);
verifyInvoked(concept, reportPlugin1, reportPlugin2, selectableReportPlugin1);
verifyNotInvoked(concept, reportPlugin3, selectableReportPlugin2);
verifyInvoked(constraint, reportPlugin1, reportPlugin2, selectableReportPlugin1);
verifyNotInvoked(constraint, reportPlugin3, selectableReportPlugin2);
verifyGroup();
}
Aggregations