refactor: hide telemetry field api by default

This commit is contained in:
lingniu
2026-07-01 08:04:59 +08:00
parent 80d3afa80a
commit e745419f76
4 changed files with 10 additions and 6 deletions

View File

@@ -154,6 +154,7 @@ public class EventHistoryAutoConfiguration {
@Bean
@ConditionalOnBean(TdengineHistoryReader.class)
@ConditionalOnProperty(prefix = "lingniu.ingest.tdengine-history", name = "telemetry-fields-enabled", havingValue = "true")
@ConditionalOnMissingBean
public TelemetryFieldHistoryController telemetryFieldHistoryController(TdengineHistoryReader reader) {
return new TelemetryFieldHistoryController(reader);

View File

@@ -120,14 +120,14 @@ class EventHistoryAutoConfigurationTest {
}
@Test
void createsGenericLocationAndTelemetryControllersWhenTdengineReaderExists() {
void createsGenericLocationAndRawControllersWithoutTelemetryFieldsByDefault() {
contextRunner
.withPropertyValues("lingniu.ingest.event-history.enabled=true")
.withBean(TdengineHistoryReader.class, () -> mock(TdengineHistoryReader.class))
.run(context -> {
assertThat(context).hasSingleBean(LocationHistoryController.class);
assertThat(context).hasSingleBean(RawFrameHistoryController.class);
assertThat(context).hasSingleBean(TelemetryFieldHistoryController.class);
assertThat(context).doesNotHaveBean(TelemetryFieldHistoryController.class);
assertThat(context).doesNotHaveBean(Jt808LocationHistoryController.class);
assertThat(context).doesNotHaveBean(Jt808RawFrameHistoryController.class);
});
@@ -152,9 +152,11 @@ class EventHistoryAutoConfigurationTest {
}
@Test
void createsTelemetryFieldHistoryControllerWhenTdengineReaderExists() {
void createsTelemetryFieldHistoryControllerWhenTelemetryFieldsAreEnabled() {
contextRunner
.withPropertyValues("lingniu.ingest.event-history.enabled=true")
.withPropertyValues(
"lingniu.ingest.event-history.enabled=true",
"lingniu.ingest.tdengine-history.telemetry-fields-enabled=true")
.withBean(TdengineHistoryReader.class, () -> mock(TdengineHistoryReader.class))
.run(context -> assertThat(context).hasSingleBean(TelemetryFieldHistoryController.class));
}