use of com.buschmais.jqassistant.core.rule.api.model.Constraint 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.rule.api.model.Constraint 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.rule.api.model.Constraint in project jqa-core-framework by buschmais.
the class XmlReportTestHelper method createXmlReportWithConstraints.
/**
* Creates a test report with {@link Constraint}.
*
* @return The test report.
* @throws ReportException
* If the test fails.
*/
public File createXmlReportWithConstraints() throws ReportException {
xmlReportWriter.begin();
Constraint constraint = Constraint.builder().id("my:Constraint").description("My constraint description").severity(Severity.BLOCKER).executable(new CypherExecutable("match...")).verification(ROW_COUNT_VERIFICATION).report(Report.builder().build()).build();
Map<String, Severity> constraints = new HashMap<>();
constraints.put("my:Constraint", Severity.INFO);
Group group = Group.builder().id("default").description("My group").constraints(constraints).build();
xmlReportWriter.beginGroup(group);
xmlReportWriter.beginConstraint(constraint);
List<Map<String, Object>> rows = new ArrayList<>();
rows.add(createRow());
Result<Constraint> result = Result.<Constraint>builder().rule(constraint).status(Result.Status.FAILURE).severity(Severity.CRITICAL).columnNames(Arrays.asList(C1, C2)).rows(rows).build();
xmlReportWriter.setResult(result);
xmlReportWriter.endConstraint();
xmlReportWriter.endGroup();
xmlReportWriter.end();
return xmlReportWriter.getXmlReportFile();
}
use of com.buschmais.jqassistant.core.rule.api.model.Constraint 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.Constraint 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