| | |
| | | verify(registry).synchronize(any()); |
| | | } |
| | | |
| | | /** 装配失败(例如缺少口令环境变量)时不能把状态改成"已启用",免得留下库里启用、运行时没实例的假状态。 */ |
| | | @Test |
| | | void failedEnableKeepsAdapterDisabledAndSurfacesTheReason() |
| | | { |
| | | adapter.setStatus("1"); |
| | | when(adapterMapper.selectDeviceAdapterById(7L)).thenReturn(adapter); |
| | | org.mockito.Mockito.doThrow(new DeviceAdapterException("缺少厂商库连接口令:请设置环境变量 X")) |
| | | .when(registry).synchronize(any()); |
| | | |
| | | DeviceAdapterException exception = assertThrows(DeviceAdapterException.class, |
| | | () -> service.changeStatus(7L, true, "admin")); |
| | | |
| | | assertTrue(exception.getMessage().contains("缺少厂商库连接口令")); |
| | | verify(adapterMapper, never()).updateDeviceAdapterStatus(any(), any(), any()); |
| | | } |
| | | |
| | | /** 单行配置有问题不得拦住后端启动:记下原因,由发现轮询按周期重试并持久化失败。 */ |
| | | @Test |
| | | void startupRestoreSurvivesOneBrokenAdapterRow() |
| | | { |
| | | TDeviceAdapter vendor = new TDeviceAdapter(); |
| | | vendor.setAdapterId(9L); |
| | | vendor.setAdapterCode("neware76"); |
| | | vendor.setAdapterName("新威 7.6 那台"); |
| | | vendor.setAdapterType("NEWARE_MYSQL"); |
| | | vendor.setHost("26.70.208.249"); |
| | | vendor.setPort(3306); |
| | | vendor.setPollIntervalMs(60000); |
| | | vendor.setTimezoneId("Asia/Hong_Kong"); |
| | | vendor.setStatus("0"); |
| | | vendor.setCapabilities("{\"discovery\":true,\"realtimeObservation\":true,\"historyDownload\":true,\"control\":false}"); |
| | | when(adapterMapper.selectEnabledDeviceAdapters()).thenReturn(List.of(vendor)); |
| | | org.mockito.Mockito.doThrow(new DeviceAdapterException("缺少厂商库连接口令:请设置环境变量 X")) |
| | | .when(registry).synchronize(any()); |
| | | |
| | | service.synchronizeEnabledAdapters(); |
| | | |
| | | verify(registry).synchronize(any()); |
| | | } |
| | | |
| | | @Test |
| | | void springSelectsProductionConstructor() |
| | | { |