| | |
| | | class TTestLiveServiceImplTest |
| | | { |
| | | @Test |
| | | void persistedOfflineWarningWithoutMeasurementReplacesLiveHintAndSurvivesRefresh() |
| | | { |
| | | TTest test = test("RECEIVING"); |
| | | var mapper = mock(TTestMapper.class); |
| | | TTestWarningException warning = new TTestWarningException(); |
| | | warning.setExceptionId(21L); |
| | | warning.setExceptionType("DEVICE_OFFLINE"); |
| | | warning.setSourceType("CABINET_CHANNEL"); |
| | | warning.setSourceIdentity("dev-sim:1:1:0:1"); |
| | | warning.setMetricCode("DEVICE_ONLINE"); |
| | | warning.setExceptionStatus("OPEN"); |
| | | when(mapper.selectWarningExceptions(10L, "OPEN")).thenReturn(List.of(warning)); |
| | | var service = liveService(test, Instant.now(), false, DeviceWorkStatus.WORKING, mapper); |
| | | |
| | | for (int attempt = 0; attempt < 2; attempt++) { |
| | | var alarms = service.current(10L).exceptions(); |
| | | assertEquals(1, alarms.size()); |
| | | assertEquals(21L, alarms.get(0).get("exceptionId")); |
| | | assertEquals("DEVICE_OFFLINE", alarms.get(0).get("exceptionType")); |
| | | } |
| | | test.setReceptionStatus("PAUSED"); |
| | | assertTrue(service.current(10L).exceptions().isEmpty()); |
| | | test.setReceptionStatus("ENDED"); |
| | | assertTrue(service.current(10L).exceptions().isEmpty()); |
| | | } |
| | | |
| | | @Test |
| | | void receivingOfflineCabinetAndCollectorAreVisibleAsOpenAlarms() |
| | | { |
| | | TTest test = test("RECEIVING"); |
| | | test.getBatteries().get(0).setCollectorId(7L); |
| | | var service = liveService(test, Instant.now(), false); |
| | | |
| | | var alarms = service.current(10L).exceptions(); |
| | | |
| | | assertEquals(2, alarms.size()); |
| | | assertTrue(alarms.stream().allMatch(item -> "OPEN".equals(item.get("status")))); |
| | | assertTrue(alarms.stream().anyMatch(item -> "COLLECTOR".equals(item.get("sourceType")))); |
| | | assertTrue(alarms.stream().anyMatch(item -> "CABINET_CHANNEL".equals(item.get("sourceType")))); |
| | | } |
| | | |
| | | @Test |
| | | void nonReceivingConsoleReadsCollectorStatusWithoutRequestingMeasurements() throws Exception |
| | | { |
| | | try (var simulator = new com.battery.device.simulator.BtsDevelopmentSimulator(0)) |