Search in sources :

Example 6 with Concept

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);
}
Also used : Concept(com.buschmais.jqassistant.core.rule.api.model.Concept) ConceptDescriptor(com.buschmais.jqassistant.core.analysis.api.model.ConceptDescriptor) Result(com.buschmais.jqassistant.core.report.api.model.Result)

Example 7 with Concept

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();
}
Also used : Concept(com.buschmais.jqassistant.core.rule.api.model.Concept) Test(org.junit.jupiter.api.Test)

Example 8 with Concept

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();
}
Also used : Concept(com.buschmais.jqassistant.core.rule.api.model.Concept) JavaSuppressDescriptor(com.buschmais.jqassistant.plugin.java.api.model.JavaSuppressDescriptor)

Example 9 with Concept

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();
}
Also used : Concept(com.buschmais.jqassistant.core.rule.api.model.Concept) Constraint(com.buschmais.jqassistant.core.rule.api.model.Constraint) Test(org.junit.jupiter.api.Test)

Example 10 with Concept

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");
}
Also used : Concept(com.buschmais.jqassistant.core.rule.api.model.Concept) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Constraint(com.buschmais.jqassistant.core.rule.api.model.Constraint) Result(com.buschmais.jqassistant.core.report.api.model.Result) Test(org.junit.jupiter.api.Test)

Aggregations

Concept (com.buschmais.jqassistant.core.rule.api.model.Concept)12 Test (org.junit.jupiter.api.Test)8 Constraint (com.buschmais.jqassistant.core.rule.api.model.Constraint)6 Result (com.buschmais.jqassistant.core.report.api.model.Result)4 StringContains.containsString (org.hamcrest.core.StringContains.containsString)3 CypherExecutable (com.buschmais.jqassistant.core.rule.api.model.CypherExecutable)2 Group (com.buschmais.jqassistant.core.rule.api.model.Group)2 Severity (com.buschmais.jqassistant.core.rule.api.model.Severity)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConceptDescriptor (com.buschmais.jqassistant.core.analysis.api.model.ConceptDescriptor)1 JavaSuppressDescriptor (com.buschmais.jqassistant.plugin.java.api.model.JavaSuppressDescriptor)1