Save time series strategies: fixed tests after merging with CF

This commit is contained in:
Dmytro Skarzhynets 2025-02-24 11:40:17 +02:00
parent 45a3730708
commit 90d6dc4ef2
No known key found for this signature in database
GPG Key ID: 2B51652F224037DF
2 changed files with 15 additions and 3 deletions

View File

@ -78,7 +78,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.lenient;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@ -136,7 +135,7 @@ class DefaultTelemetrySubscriptionServiceTest {
@BeforeEach @BeforeEach
void setup() { void setup() {
telemetryService = new DefaultTelemetrySubscriptionService(attrService, tsService, tbEntityViewService, apiUsageClient, apiUsageStateService,calculatedFieldQueueService); telemetryService = new DefaultTelemetrySubscriptionService(attrService, tsService, tbEntityViewService, apiUsageClient, apiUsageStateService, calculatedFieldQueueService);
ReflectionTestUtils.setField(telemetryService, "clusterService", clusterService); ReflectionTestUtils.setField(telemetryService, "clusterService", clusterService);
ReflectionTestUtils.setField(telemetryService, "partitionService", partitionService); ReflectionTestUtils.setField(telemetryService, "partitionService", partitionService);
ReflectionTestUtils.setField(telemetryService, "subscriptionManagerService", Optional.of(subscriptionManagerService)); ReflectionTestUtils.setField(telemetryService, "subscriptionManagerService", Optional.of(subscriptionManagerService));
@ -160,7 +159,8 @@ class DefaultTelemetrySubscriptionServiceTest {
// mock no entity views // mock no entity views
lenient().when(tbEntityViewService.findEntityViewsByTenantIdAndEntityIdAsync(tenantId, entityId)).thenReturn(immediateFuture(Collections.emptyList())); lenient().when(tbEntityViewService.findEntityViewsByTenantIdAndEntityIdAsync(tenantId, entityId)).thenReturn(immediateFuture(Collections.emptyList()));
doAnswer(inv -> { // mock that calls to CF queue service are always successful
lenient().doAnswer(inv -> {
FutureCallback<Void> callback = inv.getArgument(2); FutureCallback<Void> callback = inv.getArgument(2);
callback.onSuccess(null); callback.onSuccess(null);
return null; return null;

View File

@ -354,6 +354,9 @@ public class TbMsgTimeseriesNodeTest extends AbstractRuleNodeUpgradeTest {
.entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3))) .entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3)))
.ttl(extractTtlAsSeconds(tenantProfile)) .ttl(extractTtlAsSeconds(tenantProfile))
.strategy(TimeseriesSaveRequest.Strategy.SAVE_ALL) .strategy(TimeseriesSaveRequest.Strategy.SAVE_ALL)
.previousCalculatedFieldIds(msg.getPreviousCalculatedFieldIds())
.tbMsgId(msg.getId())
.tbMsgType(msg.getInternalType())
.build(); .build();
node.onMsg(ctxMock, msg); node.onMsg(ctxMock, msg);
@ -389,6 +392,9 @@ public class TbMsgTimeseriesNodeTest extends AbstractRuleNodeUpgradeTest {
.entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3))) .entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3)))
.ttl(extractTtlAsSeconds(tenantProfile)) .ttl(extractTtlAsSeconds(tenantProfile))
.strategy(TimeseriesSaveRequest.Strategy.SAVE_ALL) .strategy(TimeseriesSaveRequest.Strategy.SAVE_ALL)
.previousCalculatedFieldIds(msg.getPreviousCalculatedFieldIds())
.tbMsgId(msg.getId())
.tbMsgType(msg.getInternalType())
.build(); .build();
node.onMsg(ctxMock, msg); node.onMsg(ctxMock, msg);
@ -424,6 +430,9 @@ public class TbMsgTimeseriesNodeTest extends AbstractRuleNodeUpgradeTest {
.entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3))) .entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3)))
.ttl(extractTtlAsSeconds(tenantProfile)) .ttl(extractTtlAsSeconds(tenantProfile))
.strategy(TimeseriesSaveRequest.Strategy.WS_ONLY) .strategy(TimeseriesSaveRequest.Strategy.WS_ONLY)
.previousCalculatedFieldIds(msg.getPreviousCalculatedFieldIds())
.tbMsgId(msg.getId())
.tbMsgType(msg.getInternalType())
.build(); .build();
node.onMsg(ctxMock, msg); node.onMsg(ctxMock, msg);
@ -463,6 +472,9 @@ public class TbMsgTimeseriesNodeTest extends AbstractRuleNodeUpgradeTest {
.entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3))) .entry(new BasicTsKvEntry(123L, new DoubleDataEntry("temperature", 22.3)))
.ttl(extractTtlAsSeconds(tenantProfile)) .ttl(extractTtlAsSeconds(tenantProfile))
.strategy(TimeseriesSaveRequest.Strategy.SAVE_ALL) .strategy(TimeseriesSaveRequest.Strategy.SAVE_ALL)
.previousCalculatedFieldIds(msg.getPreviousCalculatedFieldIds())
.tbMsgId(msg.getId())
.tbMsgType(msg.getInternalType())
.build(); .build();
node.onMsg(ctxMock, msg); node.onMsg(ctxMock, msg);