docs: align jt808 mileage metric design

This commit is contained in:
lingniu
2026-07-01 09:36:57 +08:00
parent d9329f4364
commit 74fbdd2b1a
2 changed files with 41 additions and 9 deletions

View File

@@ -2,7 +2,10 @@ package com.lingniu.ingest.vehiclestat;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
@@ -15,4 +18,30 @@ class VehicleStatRepositoryContractTest {
.map(Method::getName))
.containsExactlyInAnyOrder("recordDailyMileageSample", "findDailyStat");
}
@Test
void jt808MileagePlanDocumentsMetricTableDiffOnly() throws IOException {
String plan = Files.readString(repositoryRoot()
.resolve("docs/superpowers/plans/2026-06-30-kafka-streaming-mileage.md"));
assertThat(plan)
.contains("Runtime state: none outside `vehicle_stat_metric`")
.contains("daily_mileage_km = last_total_mileage_km - first_total_mileage_km")
.contains("Do not create or write a protocol-specific JT808 daily-mileage table.")
.doesNotContain("Redis `Jt808MileageStateStore`")
.doesNotContain("REDIS_HOST")
.doesNotContain("GPS segment distance")
.doesNotContain("speed integral");
}
private static Path repositoryRoot() {
Path path = Path.of("").toAbsolutePath();
while (path != null && !Files.exists(path.resolve("docs/superpowers/plans"))) {
path = path.getParent();
}
if (path == null) {
throw new IllegalStateException("repository root not found");
}
return path;
}
}