use of com.buschmais.jqassistant.core.rule.api.model.Constraint in project jqa-core-framework by buschmais.
the class TransactionalVisitorTest method skipConstraint.
@Test
void skipConstraint() throws RuleException {
Constraint constraint = mock(Constraint.class);
visitor.skipConstraint(constraint, MAJOR);
verify(delegate).skipConstraint(constraint, MAJOR);
verifySuccessfulTransaction();
}
use of com.buschmais.jqassistant.core.rule.api.model.Constraint in project jqa-core-framework by buschmais.
the class TransactionalVisitorTest method runtimeException.
@Test
void runtimeException() throws RuleException {
Constraint constraint = mock(Constraint.class);
doThrow(new NullPointerException()).when(delegate).visitConstraint(constraint, MAJOR);
try {
visitor.visitConstraint(constraint, MAJOR);
fail("Expecting a " + XOException.class);
} catch (RuleException e) {
verify(delegate).visitConstraint(constraint, MAJOR);
verifyFailedTransaction();
}
}
use of com.buschmais.jqassistant.core.rule.api.model.Constraint in project jqa-java-plugin by buschmais.
the class DependencyIT method packageCycles.
/**
* Verifies the constraint "dependency:PackageCycles".
*
* @throws IOException
* If the test fails.
*/
@Test
void packageCycles() throws Exception {
scanClassPathDirectory(getClassesDirectory(A.class));
assertThat(validateConstraint("dependency:PackageCycles").getStatus(), equalTo(FAILURE));
store.beginTransaction();
Map<String, Result<Constraint>> constraintViolations = reportPlugin.getConstraintResults();
Matcher<Iterable<? super Result<Constraint>>> matcher = hasItem(result(constraint("dependency:PackageCycles")));
assertThat(constraintViolations.values(), matcher);
Result<Constraint> result = constraintViolations.get("dependency:PackageCycles");
List<Map<String, Object>> rows = result.getRows();
assertThat(rows.size(), equalTo(2));
for (Map<String, Object> row : rows) {
PackageDescriptor p = (PackageDescriptor) row.get("Package");
assertThat(p.getFullQualifiedName(), anyOf(equalTo(A.class.getPackage().getName()), equalTo(B.class.getPackage().getName())));
}
store.commitTransaction();
}
use of com.buschmais.jqassistant.core.rule.api.model.Constraint 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.Constraint in project jqa-core-framework by buschmais.
the class ReportHelperTest method failedConstraintsWithOverriddenSeverity.
@Test
void failedConstraintsWithOverriddenSeverity() {
Map<String, Object> infoRow = new HashMap<>();
infoRow.put("InfoElement", "InfoValue");
Result<Constraint> infoConstraintResult = mockResult("test:infoConstraint", Constraint.class, Result.Status.FAILURE, Severity.INFO, Severity.MINOR, 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, Severity.MAJOR, 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, Severity.CRITICAL, 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.MAJOR, Severity.CRITICAL, inMemoryReportWriter);
assertThat(violations, equalTo(1));
verifyMessages(debugMessages, ReportHelper.CONSTRAINT_VIOLATION_HEADER, "Constraint: test:infoConstraint", "Severity: MINOR (from INFO)", "InfoElement=InfoValue");
verifyMessages(warnMessages, ReportHelper.CONSTRAINT_VIOLATION_HEADER, "Constraint: test:minorConstraint", "Severity: MAJOR (from MINOR)", "MinorElement=MinorValue");
verifyMessages(errorMessages, ReportHelper.CONSTRAINT_VIOLATION_HEADER, "Constraint: test:majorConstraint", "Severity: CRITICAL (from MAJOR)", "MajorElement=MajorValue");
}
Aggregations