TenantIdLoaderTest fix

This commit is contained in:
dashevchenko 2024-02-09 16:13:45 +02:00
parent c0f9ef8a6d
commit aa24da06ea
4 changed files with 21 additions and 0 deletions

View File

@ -633,6 +633,10 @@ public class EntityQueryControllerTest extends AbstractControllerTest {
Assert.assertEquals(10, data.getTotalPages());
Assert.assertTrue(data.hasNext());
Assert.assertEquals(10, data.getData().size());
data.getData().forEach(entityData -> {
assertThat(entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("queueName")).asString().isNotBlank();
assertThat(entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("serviceId")).asString().isNotBlank();
});
EntityCountQuery countQuery = new EntityCountQuery(entityTypeFilter);

View File

@ -69,6 +69,7 @@ import org.thingsboard.server.dao.notification.NotificationTargetService;
import org.thingsboard.server.dao.notification.NotificationTemplateService;
import org.thingsboard.server.dao.ota.OtaPackageService;
import org.thingsboard.server.dao.queue.QueueService;
import org.thingsboard.server.dao.queue.QueueStatsService;
import org.thingsboard.server.dao.relation.RelationService;
import org.thingsboard.server.dao.resource.ResourceService;
import org.thingsboard.server.dao.rule.RuleChainService;
@ -314,6 +315,8 @@ public interface TbContext {
QueueService getQueueService();
QueueStatsService getQueueStatsService();
ListeningExecutor getMailExecutor();
ListeningExecutor getSmsExecutor();

View File

@ -35,6 +35,7 @@ import org.thingsboard.server.common.data.id.NotificationTargetId;
import org.thingsboard.server.common.data.id.NotificationTemplateId;
import org.thingsboard.server.common.data.id.OtaPackageId;
import org.thingsboard.server.common.data.id.QueueId;
import org.thingsboard.server.common.data.id.QueueStatsId;
import org.thingsboard.server.common.data.id.RpcId;
import org.thingsboard.server.common.data.id.RuleChainId;
import org.thingsboard.server.common.data.id.RuleNodeId;
@ -141,6 +142,9 @@ public class TenantIdLoader {
case NOTIFICATION_RULE:
tenantEntity = ctx.getNotificationRuleService().findNotificationRuleById(ctxTenantId, new NotificationRuleId(id));
break;
case QUEUE_STATS:
tenantEntity = ctx.getQueueStatsService().findQueueStatsById(ctxTenantId, new QueueStatsId(id));
break;
default:
throw new RuntimeException("Unexpected entity type: " + entityId.getEntityType());
}

View File

@ -56,6 +56,7 @@ import org.thingsboard.server.common.data.notification.rule.NotificationRule;
import org.thingsboard.server.common.data.notification.targets.NotificationTarget;
import org.thingsboard.server.common.data.notification.template.NotificationTemplate;
import org.thingsboard.server.common.data.queue.Queue;
import org.thingsboard.server.common.data.queue.QueueStats;
import org.thingsboard.server.common.data.rpc.Rpc;
import org.thingsboard.server.common.data.rule.RuleChain;
import org.thingsboard.server.common.data.rule.RuleNode;
@ -73,6 +74,7 @@ import org.thingsboard.server.dao.notification.NotificationTargetService;
import org.thingsboard.server.dao.notification.NotificationTemplateService;
import org.thingsboard.server.dao.ota.OtaPackageService;
import org.thingsboard.server.dao.queue.QueueService;
import org.thingsboard.server.dao.queue.QueueStatsService;
import org.thingsboard.server.dao.resource.ResourceService;
import org.thingsboard.server.dao.rule.RuleChainService;
import org.thingsboard.server.dao.user.UserService;
@ -135,6 +137,8 @@ public class TenantIdLoaderTest {
private NotificationRequestService notificationRequestService;
@Mock
private NotificationRuleService notificationRuleService;
@Mock
private QueueStatsService queueStatsService;
private TenantId tenantId;
private TenantProfileId tenantProfileId;
@ -352,6 +356,12 @@ public class TenantIdLoaderTest {
when(ctx.getNotificationRuleService()).thenReturn(notificationRuleService);
doReturn(notificationRule).when(notificationRuleService).findNotificationRuleById(eq(tenantId), any());
break;
case QUEUE_STATS:
QueueStats queueStats = new QueueStats();
queueStats.setTenantId(tenantId);
when(ctx.getQueueStatsService()).thenReturn(queueStatsService);
doReturn(queueStats).when(queueStatsService).findQueueStatsById(eq(tenantId), any());
break;
default:
throw new RuntimeException("Unexpected originator EntityType " + entityType);
}