xyc
3 天以前 1c9505d00bd076898cdc5a7d916106e175a91119
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.trafficaudit.freightforecast.service;
 
import com.trafficaudit.freightforecast.entity.FreightForecastAboveHistory;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
 
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
 
class FreightForecastAboveHistorySeedLoaderTest {
 
    @Test
    void loadsTheVerifiedOctoberHistorySeed() throws Exception {
        List<FreightForecastAboveHistory> rows;
        try (InputStream input = new ClassPathResource(
                "freight-forecast-above-history-2026-10.tsv").getInputStream()) {
            rows = FreightForecastAboveHistorySeedLoader.load(input);
        }
 
        assertEquals(636, rows.size());
        assertEquals(2026, rows.get(0).getStatYear());
        assertEquals("2026-10", rows.get(0).getThroughPeriod());
        assertEquals(3, rows.stream()
                .filter(row -> Boolean.TRUE.equals(row.getCorrected()))
                .count());
        assertEquals(4_843_359.17407395,
                rows.stream().mapToDouble(FreightForecastAboveHistory::getCumulativeForecast).sum()
                        / 10000.0, 0.000001);
        assertEquals(4_843_322.66069326,
                rows.stream().mapToDouble(FreightForecastAboveHistory::getSourceCumulativeForecast).sum()
                        / 10000.0, 0.000001);
 
        Set<String> names = new HashSet<>();
        for (FreightForecastAboveHistory row : rows) {
            assertTrue(names.add(row.getEnterpriseName()));
            assertTrue(row.getCity() != null && row.getCity().endsWith("\u5e02")
                    || "\u6069\u65bd\u5dde".equals(row.getCity())
                    || "\u795e\u519c\u67b6\u6797\u533a".equals(row.getCity()));
        }
    }
}