| | |
| | | } |
| | | |
| | | @Test |
| | | void upgradesLegacyCollectorDiscoveryStateWithSamplingDefaults() |
| | | { |
| | | AtomicReference<Object> stored = new AtomicReference<>("{\"version\":1,\"devices\":[]," |
| | | + "\"collectors\":[{\"collectorId\":1,\"deviceCode\":\"dev-sim-collector-1\"," |
| | | + "\"ip\":\"127.0.1.2\",\"mac\":\"02:43:00:00:00:01\"," |
| | | + "\"name\":\"模拟采集器\",\"manufacturer\":\"开发模拟器\"," |
| | | + "\"model\":\"Virtual Collector\",\"channelCount\":2,\"online\":true}]," |
| | | + "\"nextDeviceId\":1,\"nextCollectorId\":2,\"tombstones\":[]}"); |
| | | |
| | | SimulatorState restored = store(stored).loadOrInitialize(state(1, "127.0.0.2")); |
| | | |
| | | CollectorState collector = restored.collectors().get(0); |
| | | assertEquals(1000, collector.sampleIntervalMs()); |
| | | assertEquals(1L, collector.nextSequence()); |
| | | assertEquals(List.of("S-01", "S-02"), |
| | | collector.channels().stream().map(channel -> channel.channelCode()).toList()); |
| | | assertEquals(List.of(), collector.history()); |
| | | } |
| | | |
| | | @Test |
| | | void rejectsIncompatibleVersionWithoutOverwritingIt() |
| | | { |
| | | AtomicReference<Object> stored = new AtomicReference<>("{\"version\":2,\"devices\":[]," |