Browse Source

Tests fixes

pull/7911/head
ViacheslavKlimov 3 years ago
parent
commit
ea7f876d4d
  1. 18
      dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationService.java
  2. 4
      dao/src/main/java/org/thingsboard/server/dao/usagerecord/DefaultApiLimitService.java
  3. 2
      dao/src/test/resources/application-test.properties

18
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<HasId<?>> findEntity(TenantId tenantId, EntityId entityId) {
return Optional.ofNullable(findNotificationById(tenantId, new NotificationId(entityId.getId())));
}
@Override
public EntityType getEntityType() {
return EntityType.NOTIFICATION;
}
}

4
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);
}

2
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

Loading…
Cancel
Save