TenantIdLoaderTest fix
This commit is contained in:
parent
c0f9ef8a6d
commit
aa24da06ea
@ -633,6 +633,10 @@ public class EntityQueryControllerTest extends AbstractControllerTest {
|
|||||||
Assert.assertEquals(10, data.getTotalPages());
|
Assert.assertEquals(10, data.getTotalPages());
|
||||||
Assert.assertTrue(data.hasNext());
|
Assert.assertTrue(data.hasNext());
|
||||||
Assert.assertEquals(10, data.getData().size());
|
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);
|
EntityCountQuery countQuery = new EntityCountQuery(entityTypeFilter);
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,7 @@ import org.thingsboard.server.dao.notification.NotificationTargetService;
|
|||||||
import org.thingsboard.server.dao.notification.NotificationTemplateService;
|
import org.thingsboard.server.dao.notification.NotificationTemplateService;
|
||||||
import org.thingsboard.server.dao.ota.OtaPackageService;
|
import org.thingsboard.server.dao.ota.OtaPackageService;
|
||||||
import org.thingsboard.server.dao.queue.QueueService;
|
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.relation.RelationService;
|
||||||
import org.thingsboard.server.dao.resource.ResourceService;
|
import org.thingsboard.server.dao.resource.ResourceService;
|
||||||
import org.thingsboard.server.dao.rule.RuleChainService;
|
import org.thingsboard.server.dao.rule.RuleChainService;
|
||||||
@ -314,6 +315,8 @@ public interface TbContext {
|
|||||||
|
|
||||||
QueueService getQueueService();
|
QueueService getQueueService();
|
||||||
|
|
||||||
|
QueueStatsService getQueueStatsService();
|
||||||
|
|
||||||
ListeningExecutor getMailExecutor();
|
ListeningExecutor getMailExecutor();
|
||||||
|
|
||||||
ListeningExecutor getSmsExecutor();
|
ListeningExecutor getSmsExecutor();
|
||||||
|
|||||||
@ -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.NotificationTemplateId;
|
||||||
import org.thingsboard.server.common.data.id.OtaPackageId;
|
import org.thingsboard.server.common.data.id.OtaPackageId;
|
||||||
import org.thingsboard.server.common.data.id.QueueId;
|
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.RpcId;
|
||||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||||
import org.thingsboard.server.common.data.id.RuleNodeId;
|
import org.thingsboard.server.common.data.id.RuleNodeId;
|
||||||
@ -141,6 +142,9 @@ public class TenantIdLoader {
|
|||||||
case NOTIFICATION_RULE:
|
case NOTIFICATION_RULE:
|
||||||
tenantEntity = ctx.getNotificationRuleService().findNotificationRuleById(ctxTenantId, new NotificationRuleId(id));
|
tenantEntity = ctx.getNotificationRuleService().findNotificationRuleById(ctxTenantId, new NotificationRuleId(id));
|
||||||
break;
|
break;
|
||||||
|
case QUEUE_STATS:
|
||||||
|
tenantEntity = ctx.getQueueStatsService().findQueueStatsById(ctxTenantId, new QueueStatsId(id));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unexpected entity type: " + entityId.getEntityType());
|
throw new RuntimeException("Unexpected entity type: " + entityId.getEntityType());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.targets.NotificationTarget;
|
||||||
import org.thingsboard.server.common.data.notification.template.NotificationTemplate;
|
import org.thingsboard.server.common.data.notification.template.NotificationTemplate;
|
||||||
import org.thingsboard.server.common.data.queue.Queue;
|
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.rpc.Rpc;
|
||||||
import org.thingsboard.server.common.data.rule.RuleChain;
|
import org.thingsboard.server.common.data.rule.RuleChain;
|
||||||
import org.thingsboard.server.common.data.rule.RuleNode;
|
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.notification.NotificationTemplateService;
|
||||||
import org.thingsboard.server.dao.ota.OtaPackageService;
|
import org.thingsboard.server.dao.ota.OtaPackageService;
|
||||||
import org.thingsboard.server.dao.queue.QueueService;
|
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.resource.ResourceService;
|
||||||
import org.thingsboard.server.dao.rule.RuleChainService;
|
import org.thingsboard.server.dao.rule.RuleChainService;
|
||||||
import org.thingsboard.server.dao.user.UserService;
|
import org.thingsboard.server.dao.user.UserService;
|
||||||
@ -135,6 +137,8 @@ public class TenantIdLoaderTest {
|
|||||||
private NotificationRequestService notificationRequestService;
|
private NotificationRequestService notificationRequestService;
|
||||||
@Mock
|
@Mock
|
||||||
private NotificationRuleService notificationRuleService;
|
private NotificationRuleService notificationRuleService;
|
||||||
|
@Mock
|
||||||
|
private QueueStatsService queueStatsService;
|
||||||
|
|
||||||
private TenantId tenantId;
|
private TenantId tenantId;
|
||||||
private TenantProfileId tenantProfileId;
|
private TenantProfileId tenantProfileId;
|
||||||
@ -352,6 +356,12 @@ public class TenantIdLoaderTest {
|
|||||||
when(ctx.getNotificationRuleService()).thenReturn(notificationRuleService);
|
when(ctx.getNotificationRuleService()).thenReturn(notificationRuleService);
|
||||||
doReturn(notificationRule).when(notificationRuleService).findNotificationRuleById(eq(tenantId), any());
|
doReturn(notificationRule).when(notificationRuleService).findNotificationRuleById(eq(tenantId), any());
|
||||||
break;
|
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:
|
default:
|
||||||
throw new RuntimeException("Unexpected originator EntityType " + entityType);
|
throw new RuntimeException("Unexpected originator EntityType " + entityType);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user