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