Search in sources :

Example 6 with AuditLog

use of org.drools.scenariosimulation.api.model.AuditLog in project drools-wb by kiegroup.

the class RunnerReportServiceImplTest method getReportDMN.

@Test
public void getReportDMN() {
    AuditLog auditLog = new AuditLog();
    IntStream.range(0, 6).forEach(index -> auditLog.addAuditLogLine(getAuditLogLine()));
    String report = runnerReportServiceImpl.getReport(getSimulationRunMetadata(auditLog), ScenarioSimulationModel.Type.DMN);
    assertNotNull(report);
    assertFalse(report.isEmpty());
    String[] reportLine = report.split("\\r\\n");
    assertTrue(report.contains("DECISION"));
    assertFalse(report.contains("RULE"));
    assertEquals(7 + auditLog.getAuditLogLines().size(), reportLine.length);
    for (int i = 0; i < reportLine.length; i++) {
        assertNotNull(reportLine[i]);
    }
}
Also used : AuditLog(org.drools.scenariosimulation.api.model.AuditLog) Test(org.junit.Test)

Example 7 with AuditLog

use of org.drools.scenariosimulation.api.model.AuditLog in project drools-wb by kiegroup.

the class ScenarioCsvDownloadReportTest method printRulesCounterLine.

@Test
public void printRulesCounterLine() throws IOException {
    StringBuilder stringBuilder = new StringBuilder();
    CSVPrinter printer = getCSVPrinter(stringBuilder);
    AuditLog auditLog = new AuditLog();
    auditLog.addAuditLogLine(getAuditLogLine());
    SimulationRunMetadata simulationRunMetadata = getSimulationRunMetadata(auditLog);
    Map.Entry<String, Integer> entry = simulationRunMetadata.getOutputCounter().entrySet().iterator().next();
    scenarioCsvDownloadReport.printRulesCounterLine(printer, entry.getKey(), entry.getValue());
    String retrieved = stringBuilder.toString();
    List<String> data = Arrays.asList("\"" + entry.getKey() + "\"", String.valueOf(entry.getValue()));
    commonCheckRetrievedString(retrieved, data);
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) SimulationRunMetadata(org.drools.scenariosimulation.api.model.SimulationRunMetadata) HashMap(java.util.HashMap) Map(java.util.Map) AuditLog(org.drools.scenariosimulation.api.model.AuditLog) Test(org.junit.Test)

Example 8 with AuditLog

use of org.drools.scenariosimulation.api.model.AuditLog in project drools-wb by kiegroup.

the class ScenarioCsvDownloadReportTest method commonGetReport.

private void commonGetReport(ScenarioSimulationModel.Type type, String[] overallStats, String[] counterHeader, String[] auditHeader) {
    AuditLog auditLog = new AuditLog();
    IntStream.range(0, 6).forEach(index -> auditLog.addAuditLogLine(getAuditLogLine()));
    SimulationRunMetadata simulationRunMetadata = getSimulationRunMetadata(auditLog);
    String retrieved = scenarioCsvDownloadReport.getReport(simulationRunMetadata, type);
    assertNotNull(retrieved);
    String[] retrievedLines = retrieved.split("\r\n");
    commonCheckHeader(overallStats, retrievedLines[0]);
    List<String> overallStatsData = Arrays.asList(String.valueOf(simulationRunMetadata.getAvailable()), String.valueOf(simulationRunMetadata.getExecuted()), String.valueOf(simulationRunMetadata.getCoveragePercentage()));
    commonCheckRetrievedString(retrievedLines[1], overallStatsData);
    assertTrue(retrievedLines[2].isEmpty());
    commonCheckHeader(counterHeader, retrievedLines[3]);
    Map.Entry<String, Integer> entry = simulationRunMetadata.getOutputCounter().entrySet().iterator().next();
    List<String> rulesCounterData = Arrays.asList("\"" + entry.getKey() + "\"", String.valueOf(entry.getValue()));
    commonCheckRetrievedString(retrievedLines[4], rulesCounterData);
    assertTrue(retrievedLines[5].isEmpty());
    commonCheckHeader(auditHeader, retrievedLines[6]);
    for (int i = 7; i < retrievedLines.length; i++) {
        AuditLogLine auditLogLine = auditLog.getAuditLogLines().get(i - 7);
        List<String> auditData = Arrays.asList(String.valueOf(auditLogLine.getScenarioIndex()), "\"" + auditLogLine.getScenario() + "\"", String.valueOf(auditLogLine.getExecutionIndex()), "\"" + auditLogLine.getDecisionOrRuleName() + "\"", auditLogLine.getResult(), auditLogLine.getMessage().orElse(""));
        commonCheckRetrievedString(retrievedLines[i], auditData);
    }
}
Also used : AuditLogLine(org.drools.scenariosimulation.api.model.AuditLogLine) SimulationRunMetadata(org.drools.scenariosimulation.api.model.SimulationRunMetadata) HashMap(java.util.HashMap) Map(java.util.Map) AuditLog(org.drools.scenariosimulation.api.model.AuditLog)

Aggregations

AuditLog (org.drools.scenariosimulation.api.model.AuditLog)8 Test (org.junit.Test)6 SimulationRunMetadata (org.drools.scenariosimulation.api.model.SimulationRunMetadata)5 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CSVPrinter (org.apache.commons.csv.CSVPrinter)2 AuditLogLine (org.drools.scenariosimulation.api.model.AuditLogLine)2 ScenarioWithIndex (org.drools.scenariosimulation.api.model.ScenarioWithIndex)2 ScenarioResultMetadata (org.drools.scenariosimulation.backend.runner.model.ScenarioResultMetadata)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Scenario (org.drools.scenariosimulation.api.model.Scenario)1 TestUtils.commonCheckAuditLogLine (org.drools.scenariosimulation.backend.TestUtils.commonCheckAuditLogLine)1 TestUtils.getRandomlyGeneratedDMNMessageList (org.drools.scenariosimulation.backend.TestUtils.getRandomlyGeneratedDMNMessageList)1 CoverageReportView (org.drools.workbench.screens.scenariosimulation.businesscentral.client.rightpanel.coverage.CoverageReportView)1 AbstractScenarioSimulationEditorTest (org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest)1 AbstractDMODataManagementStrategy (org.drools.workbench.screens.scenariosimulation.client.editor.strategies.AbstractDMODataManagementStrategy)1 ScenarioSimulationHasBusyIndicatorDefaultErrorCallback (org.drools.workbench.screens.scenariosimulation.client.handlers.ScenarioSimulationHasBusyIndicatorDefaultErrorCallback)1 DMNMessage (org.kie.dmn.api.core.DMNMessage)1