Search in sources :

Example 1 with Concept

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)");
}
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)

Example 2 with Concept

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));
}
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)

Example 3 with Concept

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();
}
Also used : Concept(com.buschmais.jqassistant.core.rule.api.model.Concept) Group(com.buschmais.jqassistant.core.rule.api.model.Group) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Severity(com.buschmais.jqassistant.core.rule.api.model.Severity) CypherExecutable(com.buschmais.jqassistant.core.rule.api.model.CypherExecutable) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with Concept

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();
}
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 5 with Concept

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();
}
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)

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