refactor: reject legacy jt808 mileage state store
This commit is contained in:
@@ -28,6 +28,13 @@ import java.time.ZoneId;
|
|||||||
@ConditionalOnProperty(prefix = "lingniu.ingest.vehicle-stat", name = "enabled", havingValue = "true")
|
@ConditionalOnProperty(prefix = "lingniu.ingest.vehicle-stat", name = "enabled", havingValue = "true")
|
||||||
public class VehicleStatAutoConfiguration {
|
public class VehicleStatAutoConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "lingniu.ingest.vehicle-stat.jt808", name = "state-store")
|
||||||
|
public Object rejectedLegacyJt808MileageStateStore() {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"vehicle-stat.jt808.state-store has been removed; JT808 daily mileage uses vehicle_stat_metric only");
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnBean(JdbcTemplate.class)
|
@ConditionalOnBean(JdbcTemplate.class)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
|
|||||||
@@ -74,17 +74,17 @@ class VehicleStatAutoConfigurationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ignoresLegacyStateStorePropertyAndUsesMetricRepositoryOnly() {
|
void rejectsLegacyStateStorePropertyInsteadOfCreatingHiddenRuntimeMode() {
|
||||||
contextRunner
|
contextRunner
|
||||||
.withBean(JdbcTemplate.class, () -> mock(JdbcTemplate.class))
|
.withBean(JdbcTemplate.class, () -> mock(JdbcTemplate.class))
|
||||||
.withPropertyValues(
|
.withPropertyValues(
|
||||||
"lingniu.ingest.vehicle-stat.enabled=true",
|
"lingniu.ingest.vehicle-stat.enabled=true",
|
||||||
"lingniu.ingest.vehicle-stat.jt808.enabled=true",
|
"lingniu.ingest.vehicle-stat.jt808.enabled=true",
|
||||||
"lingniu.ingest.vehicle-stat.jt808.state-store=memory")
|
"lingniu.ingest.vehicle-stat.jt808.state-store=memory")
|
||||||
.run(context -> {
|
.run(context -> assertThat(context.getStartupFailure())
|
||||||
assertThat(context).hasSingleBean(Jt808MileageStreamProcessor.class);
|
.hasRootCauseInstanceOf(IllegalStateException.class)
|
||||||
assertThat(context).hasSingleBean(VehicleStatEnvelopeIngestor.class);
|
.hasMessageContaining("vehicle-stat.jt808.state-store has been removed")
|
||||||
});
|
.hasMessageContaining("vehicle_stat_metric"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user