From ea7f876d4d6e097ff9ec024c3ffd665fbea3a465 Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Mon, 20 Mar 2023 11:32:18 +0200 Subject: [PATCH] Tests fixes --- .../DefaultNotificationService.java | 18 +++++++++++++++++- .../usagerecord/DefaultApiLimitService.java | 4 +++- .../test/resources/application-test.properties | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationService.java b/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationService.java index cf34f6fcfb..20a32efbe0 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationService.java +++ b/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationService.java @@ -18,6 +18,9 @@ package org.thingsboard.server.dao.notification; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.thingsboard.server.common.data.EntityType; +import org.thingsboard.server.common.data.id.EntityId; +import org.thingsboard.server.common.data.id.HasId; import org.thingsboard.server.common.data.id.NotificationId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.UserId; @@ -26,12 +29,15 @@ import org.thingsboard.server.common.data.notification.NotificationStatus; import org.thingsboard.server.common.data.page.PageData; import org.thingsboard.server.common.data.page.PageLink; import org.thingsboard.server.common.data.page.SortOrder; +import org.thingsboard.server.dao.entity.EntityDaoService; import org.thingsboard.server.dao.sql.query.EntityKeyMapping; +import java.util.Optional; + @Service @Slf4j @RequiredArgsConstructor -public class DefaultNotificationService implements NotificationService { +public class DefaultNotificationService implements NotificationService, EntityDaoService { private final NotificationDao notificationDao; @@ -81,4 +87,14 @@ public class DefaultNotificationService implements NotificationService { return notificationDao.deleteByIdAndRecipientId(tenantId, recipientId, notificationId); } + @Override + public Optional> findEntity(TenantId tenantId, EntityId entityId) { + return Optional.ofNullable(findNotificationById(tenantId, new NotificationId(entityId.getId()))); + } + + @Override + public EntityType getEntityType() { + return EntityType.NOTIFICATION; + } + } diff --git a/dao/src/main/java/org/thingsboard/server/dao/usagerecord/DefaultApiLimitService.java b/dao/src/main/java/org/thingsboard/server/dao/usagerecord/DefaultApiLimitService.java index 7a25c70a75..24d2e4eb3a 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/usagerecord/DefaultApiLimitService.java +++ b/dao/src/main/java/org/thingsboard/server/dao/usagerecord/DefaultApiLimitService.java @@ -19,6 +19,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.thingsboard.server.common.data.EntityType; +import org.thingsboard.server.common.data.id.CustomerId; +import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.query.EntityCountQuery; import org.thingsboard.server.common.data.query.EntityTypeFilter; @@ -44,7 +46,7 @@ public class DefaultApiLimitService implements ApiLimitService { if (limit > 0) { EntityTypeFilter filter = new EntityTypeFilter(); filter.setEntityType(entityType); - long currentCount = entityService.countEntitiesByQuery(tenantId, null, new EntityCountQuery(filter)); + long currentCount = entityService.countEntitiesByQuery(tenantId, new CustomerId(EntityId.NULL_UUID), new EntityCountQuery(filter)); if (notificationRuleProcessingService != null) { notificationRuleProcessingService.process(tenantId, entityType, limit, currentCount); } diff --git a/dao/src/test/resources/application-test.properties b/dao/src/test/resources/application-test.properties index a2a21abc11..fc46ba431a 100644 --- a/dao/src/test/resources/application-test.properties +++ b/dao/src/test/resources/application-test.properties @@ -65,6 +65,8 @@ cache.specs.otaPackagesData.maxSize=100000 cache.specs.edges.timeToLiveInMinutes=1440 cache.specs.edges.maxSize=100000 +cache.specs.notificationRules.timeToLiveInMinutes=1440 +cache.specs.notificationRules.maxSize=10000 redis.connection.host=localhost redis.connection.port=6379