修正暂停停止后的设备异常展示
暂停接收和检测完成时不再把不可观测设备状态列为实时告警,保留设备事实状态并补充回归测试。
| | |
| | | assertEquals(new BigDecimal("2.500"), snapshot.get("capacityAh")); |
| | | } |
| | | |
| | | @Test |
| | | void pausedShouldNotExposeUnavailableSourceAsAlarm() |
| | | { |
| | | Instant now = Instant.parse("2026-09-02T06:00:00Z"); |
| | | TTest test = test("PAUSED"); |
| | | TTestLiveServiceImpl service = liveService(test, now, false); |
| | | |
| | | LiveState state = service.current(10L); |
| | | |
| | | assertTrue(state.exceptions().isEmpty()); |
| | | } |
| | | |
| | | private static TTest test(String receptionStatus) |
| | | { |
| | | TTest test = new TTest(); |
| | |
| | | |
| | | private static TTestLiveServiceImpl liveService(TTest test, Instant now) |
| | | { |
| | | return liveService(test, now, true); |
| | | } |
| | | |
| | | private static TTestLiveServiceImpl liveService(TTest test, Instant now, boolean online) |
| | | { |
| | | DeviceDiscoveryCandidateStore candidates = mock(DeviceDiscoveryCandidateStore.class); |
| | | BtsDevelopmentSimulator simulator = mock(BtsDevelopmentSimulator.class); |
| | | ITTestService tests = mock(ITTestService.class); |
| | |
| | | new BigDecimal("9.250"), 12L, 12L, "0", now, |
| | | java.util.Map.of()); |
| | | DeviceDiscoveryCandidateStore.ChannelCandidate channel = new DeviceDiscoveryCandidateStore.ChannelCandidate( |
| | | identity, true, DeviceWorkStatus.WORKING, now, snapshot); |
| | | identity, online, DeviceWorkStatus.WORKING, now, snapshot); |
| | | DeviceDiscoveryCandidateStore.CabinetCandidate cabinet = new DeviceDiscoveryCandidateStore.CabinetCandidate( |
| | | "dev-sim", 1L, "dev-sim", 1, 1, "127.0.0.2", "mac", "cabinet", "vendor", "model", |
| | | List.of(channel), now, now.plusSeconds(60)); |
| | |
| | | sources.add(snapshotFor(collectorSource(battery), receiving)); |
| | | } |
| | | List<Map<String, Object>> exceptions = new ArrayList<>(); |
| | | exceptions.addAll(sources.stream().filter(source -> !"COLLECTOR".equals(source.sourceType()) |
| | | && !"ONLINE".equals(source.deviceStatus()) |
| | | && !"WORKING".equals(source.deviceStatus()) && !"PAUSED".equals(source.deviceStatus())) |
| | | .map(source -> Map.<String, Object>of("sourceType", source.sourceType(), "sourceId", source.sourceId(), |
| | | "batteryNo", source.batteryNo(), "status", source.deviceStatus(), "message", "数据来源当前不可观测")) |
| | | .toList()); |
| | | if (receiving) |
| | | exceptions.addAll(sources.stream().filter(source -> !"COLLECTOR".equals(source.sourceType()) |
| | | && !"ONLINE".equals(source.deviceStatus()) |
| | | && !"WORKING".equals(source.deviceStatus()) && !"PAUSED".equals(source.deviceStatus())) |
| | | .map(source -> Map.<String, Object>of("sourceType", source.sourceType(), "sourceId", source.sourceId(), |
| | | "batteryNo", source.batteryNo(), "status", source.deviceStatus(), "message", "数据来源当前不可观测")) |
| | | .toList()); |
| | | if (mapper != null) { |
| | | mapper.selectWarningExceptions(testId, "OPEN").forEach(item -> exceptions.add(Map.of( |
| | | "exceptionId", item.getExceptionId(), "sourceType", item.getSourceType(), |