wip: enhancing

This commit is contained in:
Jan 2026-02-06 19:13:15 +01:00
parent adf3666430
commit c727bbccc2
3 changed files with 25 additions and 8 deletions

View file

@ -608,7 +608,7 @@ public final class TestCases {
.fcaFee(0.11)
.transportation(0.0)
.d2d(0.39)
.airFreight(0.01)
.airFreight(0.0)
.custom(1.72)
.repackaging(0.00)
.handling(0.00)
@ -861,7 +861,7 @@ public final class TestCases {
.fcaFee(0.02)
.transportation(7.3)
.d2d(0.0)
.airFreight(3.46)
.airFreight(0.0)
.custom(0.41)
.repackaging(0.0)
.handling(0.0)

View file

@ -11,6 +11,9 @@ import de.avatic.lcc.e2e.util.DeviationReport;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.logging.Logger;
@ -58,6 +61,15 @@ class DeviationAnalysisE2ETest extends AbstractE2ETest {
String reportContent = report.generateMarkdownTable();
System.out.println(reportContent);
logger.info(reportContent);
// Write report to file
try {
Path reportPath = Path.of("target/deviation-report.md");
Files.writeString(reportPath, reportContent);
logger.info("Deviation report written to: " + reportPath.toAbsolutePath());
} catch (IOException e) {
logger.warning("Could not write deviation report file: " + e.getMessage());
}
}
private Map<String, Object> runCalculationAndGetResults(TestCase testCase) {

View file

@ -103,19 +103,24 @@ public final class ResultComparator {
*/
private static void compareNumeric(List<String> failures, String fieldName,
double expected, Double actual, double tolerance) {
// Handle zero expected values - if expected is ~0 and actual is null, treat as pass
// (some fields are not displayed in the UI when their value is 0)
if (Math.abs(expected) < 1e-10) {
if (actual == null) {
failures.add(String.format("%s: actual value is null, expected %.6f", fieldName, expected));
// Expected ~0 and actual is null (field not shown) - this is acceptable
return;
}
// Handle zero expected values
if (Math.abs(expected) < 1e-10) {
if (Math.abs(actual) > tolerance) {
failures.add(String.format("%s: expected ~0, got %.6f", fieldName, actual));
}
return;
}
if (actual == null) {
failures.add(String.format("%s: actual value is null, expected %.6f", fieldName, expected));
return;
}
double relativeDiff = Math.abs(expected - actual) / Math.abs(expected);
if (relativeDiff > tolerance) {
failures.add(String.format(