yeg
2026-08-30 56cddf53e7e71afad29885d7fcf773a222b95f6c
ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/CollectorDisconnectRecoveryServiceImplTest.java
@@ -56,6 +56,34 @@
        verify(mapper, never()).insertCollectorExceptionInterval(any());
    }
    @Test
    void allowsAnotherDisconnectCycleAfterPreviousIntervalWasClosed()
    {
        TTestCollectorSource source = source(10L, 20L, 8L, "COL-1", "S-01");
        TTestCollectorExceptionInterval first = openInterval(99L);
        TTestCollectorExceptionInterval second = openInterval(100L);
        when(mapper.selectReceivingCollectorSources()).thenReturn(List.of(source));
        when(mapper.selectOpenCollectorException(10L, 20L, 8L, "S-01"))
                .thenReturn(null, first, null, second);
        service.reconcile(Set.of(), Instant.parse("2026-08-30T09:00:00Z"));
        service.reconcile(Set.of("COL-1"), Instant.parse("2026-08-30T09:01:00Z"));
        service.reconcile(Set.of(), Instant.parse("2026-08-30T09:02:00Z"));
        service.reconcile(Set.of("COL-1"), Instant.parse("2026-08-30T09:03:00Z"));
        verify(mapper, org.mockito.Mockito.times(2)).insertCollectorExceptionInterval(any());
        verify(mapper).closeCollectorExceptionInterval(eq(99L), any(), any());
        verify(mapper).closeCollectorExceptionInterval(eq(100L), any(), any());
    }
    private TTestCollectorExceptionInterval openInterval(Long intervalId)
    {
        TTestCollectorExceptionInterval interval = new TTestCollectorExceptionInterval();
        interval.setIntervalId(intervalId);
        interval.setIntervalStatus("OPEN");
        return interval;
    }
    private TTestCollectorSource source(Long testId, Long relationId, Long collectorId,
            String collectorCode, String channelCode)
    {