Browse Source

Merge pull request #8206 from zzzeebra/feature/test_dependency_refactor

[3.5] Feature/test dependency refactor
pull/8217/head
Andrew Shvayka 3 years ago
committed by GitHub
parent
commit
806aefdd0b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      dao/src/main/java/org/thingsboard/server/dao/entity/DefaultEntityServiceRegistry.java
  2. 122
      dao/src/test/java/org/thingsboard/server/dao/service/AbstractServiceTest.java
  3. 5
      dao/src/test/java/org/thingsboard/server/dao/service/BaseAdminSettingsServiceTest.java
  4. 22
      dao/src/test/java/org/thingsboard/server/dao/service/BaseAlarmCommentServiceTest.java
  5. 44
      dao/src/test/java/org/thingsboard/server/dao/service/BaseAlarmServiceTest.java
  6. 23
      dao/src/test/java/org/thingsboard/server/dao/service/BaseApiUsageStateServiceTest.java
  7. 26
      dao/src/test/java/org/thingsboard/server/dao/service/BaseAssetProfileServiceTest.java
  8. 42
      dao/src/test/java/org/thingsboard/server/dao/service/BaseAssetServiceTest.java
  9. 25
      dao/src/test/java/org/thingsboard/server/dao/service/BaseCustomerServiceTest.java
  10. 53
      dao/src/test/java/org/thingsboard/server/dao/service/BaseDashboardServiceTest.java
  11. 26
      dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceCredentialsServiceTest.java
  12. 32
      dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceProfileServiceTest.java
  13. 39
      dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceServiceTest.java
  14. 9
      dao/src/test/java/org/thingsboard/server/dao/service/BaseEdgeEventServiceTest.java
  15. 45
      dao/src/test/java/org/thingsboard/server/dao/service/BaseEdgeServiceTest.java
  16. 2
      dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceRegistryTest.java
  17. 43
      dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceTest.java
  18. 23
      dao/src/test/java/org/thingsboard/server/dao/service/BaseOtaPackageServiceTest.java
  19. 10
      dao/src/test/java/org/thingsboard/server/dao/service/BaseQueueServiceTest.java
  20. 5
      dao/src/test/java/org/thingsboard/server/dao/service/BaseRelationServiceTest.java
  21. 34
      dao/src/test/java/org/thingsboard/server/dao/service/BaseRuleChainServiceTest.java
  22. 14
      dao/src/test/java/org/thingsboard/server/dao/service/BaseTenantProfileServiceTest.java
  23. 78
      dao/src/test/java/org/thingsboard/server/dao/service/BaseTenantServiceTest.java
  24. 57
      dao/src/test/java/org/thingsboard/server/dao/service/BaseUserServiceTest.java
  25. 27
      dao/src/test/java/org/thingsboard/server/dao/service/BaseWidgetTypeServiceTest.java
  26. 44
      dao/src/test/java/org/thingsboard/server/dao/service/BaseWidgetsBundleServiceTest.java
  27. 6
      dao/src/test/java/org/thingsboard/server/dao/service/event/BaseEventServiceTest.java
  28. 10
      dao/src/test/java/org/thingsboard/server/dao/service/timeseries/BaseTimeseriesServiceTest.java

21
dao/src/main/java/org/thingsboard/server/dao/entity/DefaultEntityServiceRegistry.java

@ -15,27 +15,31 @@
*/
package org.thingsboard.server.dao.entity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.EntityType;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@Service
@RequiredArgsConstructor
@Slf4j
public class DefaultEntityServiceRegistry implements EntityServiceRegistry {
private final ApplicationContext applicationContext;
private final Map<EntityType, EntityDaoService> entityDaoServicesMap;
private final Map<EntityType, EntityDaoService> entityDaoServicesMap = new HashMap<>();
public DefaultEntityServiceRegistry(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
this.entityDaoServicesMap = new HashMap<>();
}
@PostConstruct
@EventListener(ContextRefreshedEvent.class)
@Order(Ordered.HIGHEST_PRECEDENCE)
public void init() {
log.debug("Initializing EntityServiceRegistry on ContextRefreshedEvent");
applicationContext.getBeansOfType(EntityDaoService.class).values().forEach(entityDaoService -> {
EntityType entityType = entityDaoService.getEntityType();
entityDaoServicesMap.put(entityType, entityDaoService);
@ -43,6 +47,7 @@ public class DefaultEntityServiceRegistry implements EntityServiceRegistry {
entityDaoServicesMap.put(EntityType.RULE_NODE, entityDaoService);
}
});
log.debug("Initialized EntityServiceRegistry total [{}] entries", entityDaoServicesMap.size());
}
@Override

122
dao/src/test/java/org/thingsboard/server/dao/service/AbstractServiceTest.java

@ -18,6 +18,8 @@ package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@ -47,44 +49,17 @@ import org.thingsboard.server.common.data.id.HasId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
import org.thingsboard.server.common.data.ota.OtaPackageType;
import org.thingsboard.server.dao.alarm.AlarmCommentService;
import org.thingsboard.server.dao.alarm.AlarmService;
import org.thingsboard.server.dao.asset.AssetProfileService;
import org.thingsboard.server.dao.asset.AssetService;
import org.thingsboard.server.dao.audit.AuditLogLevelFilter;
import org.thingsboard.server.dao.audit.AuditLogLevelMask;
import org.thingsboard.server.dao.audit.AuditLogLevelProperties;
import org.thingsboard.server.dao.component.ComponentDescriptorService;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.dashboard.DashboardService;
import org.thingsboard.server.dao.device.DeviceCredentialsService;
import org.thingsboard.server.dao.device.DeviceProfileService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.edge.EdgeEventService;
import org.thingsboard.server.dao.edge.EdgeService;
import org.thingsboard.server.dao.entity.EntityService;
import org.thingsboard.server.dao.entityview.EntityViewService;
import org.thingsboard.server.dao.event.EventService;
import org.thingsboard.server.dao.ota.OtaPackageService;
import org.thingsboard.server.dao.queue.QueueService;
import org.thingsboard.server.dao.relation.RelationService;
import org.thingsboard.server.dao.resource.ResourceService;
import org.thingsboard.server.dao.rpc.RpcService;
import org.thingsboard.server.dao.rule.RuleChainService;
import org.thingsboard.server.dao.settings.AdminSettingsService;
import org.thingsboard.server.dao.tenant.TenantProfileService;
import org.thingsboard.server.dao.tenant.TenantService;
import org.thingsboard.server.dao.timeseries.TimeseriesService;
import org.thingsboard.server.dao.usagerecord.ApiUsageStateService;
import org.thingsboard.server.dao.user.UserService;
import org.thingsboard.server.dao.widget.WidgetTypeService;
import org.thingsboard.server.dao.widget.WidgetsBundleService;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import static org.junit.Assert.assertNotNull;
@ -100,91 +75,20 @@ public abstract class AbstractServiceTest {
public static final TenantId SYSTEM_TENANT_ID = TenantId.SYS_TENANT_ID;
@Autowired
protected UserService userService;
@Autowired
protected ApiUsageStateService apiUsageStateService;
@Autowired
protected AdminSettingsService adminSettingsService;
@Autowired
protected TenantService tenantService;
@Autowired
protected CustomerService customerService;
@Autowired
protected DeviceService deviceService;
@Autowired
protected AssetService assetService;
@Autowired
protected EntityViewService entityViewService;
@Autowired
protected EntityService entityService;
@Autowired
protected DeviceCredentialsService deviceCredentialsService;
@Autowired
protected WidgetsBundleService widgetsBundleService;
@Autowired
protected WidgetTypeService widgetTypeService;
@Autowired
protected DashboardService dashboardService;
@Autowired
protected TimeseriesService tsService;
@Autowired
protected EventService eventService;
@Autowired
protected RelationService relationService;
@Autowired
protected AlarmService alarmService;
@Autowired
protected AlarmCommentService alarmCommentService;
@Autowired
protected RuleChainService ruleChainService;
@Autowired
protected EdgeService edgeService;
@Autowired
protected EdgeEventService edgeEventService;
protected TenantId tenantId;
@Autowired
private ComponentDescriptorService componentDescriptorService;
@Autowired
protected TenantProfileService tenantProfileService;
@Autowired
protected DeviceProfileService deviceProfileService;
@Autowired
protected AssetProfileService assetProfileService;
@Autowired
protected ResourceService resourceService;
@Autowired
protected OtaPackageService otaPackageService;
@Autowired
protected RpcService rpcService;
@Before
public void beforeAbstractService() {
tenantId = createTenant();
}
@Autowired
protected QueueService queueService;
@After
public void afterAbstractService() {
tenantService.deleteTenants();
}
public class IdComparator<D extends HasId> implements Comparator<D> {
@Override
@ -270,7 +174,7 @@ public abstract class AbstractServiceTest {
public TenantId createTenant() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant " + Uuids.timeBased());
tenant.setTitle("My tenant " + UUID.randomUUID());
Tenant savedTenant = tenantService.saveTenant(tenant);
assertNotNull(savedTenant);
return savedTenant.getId();

5
dao/src/test/java/org/thingsboard/server/dao/service/BaseAdminSettingsServiceTest.java

@ -20,11 +20,16 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.AdminSettings;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.settings.AdminSettingsService;
public abstract class BaseAdminSettingsServiceTest extends AbstractServiceTest {
@Autowired
AdminSettingsService adminSettingsService;
@Test
public void testFindAdminSettingsByKey() {
AdminSettings adminSettings = adminSettingsService.findAdminSettingsByKey(SYSTEM_TENANT_ID, "general");

22
dao/src/test/java/org/thingsboard/server/dao/service/BaseAlarmCommentServiceTest.java

@ -20,21 +20,22 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.alarm.Alarm;
import org.thingsboard.server.common.data.alarm.AlarmComment;
import org.thingsboard.server.common.data.alarm.AlarmCommentInfo;
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
import org.thingsboard.server.common.data.alarm.AlarmStatus;
import org.thingsboard.server.common.data.id.AssetId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.security.Authority;
import org.thingsboard.server.dao.alarm.AlarmCommentService;
import org.thingsboard.server.dao.alarm.AlarmService;
import org.thingsboard.server.dao.user.UserService;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
@ -43,19 +44,19 @@ import static org.thingsboard.server.common.data.alarm.AlarmCommentType.OTHER;
public abstract class BaseAlarmCommentServiceTest extends AbstractServiceTest {
@Autowired
AlarmService alarmService;
@Autowired
AlarmCommentService alarmCommentService;
@Autowired
UserService userService;
public static final String TEST_ALARM = "TEST_ALARM";
private TenantId tenantId;
private Alarm alarm;
private User user;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
alarm = Alarm.builder().tenantId(tenantId).originator(new AssetId(Uuids.timeBased()))
.type(TEST_ALARM)
.severity(AlarmSeverity.CRITICAL)
@ -74,7 +75,6 @@ public abstract class BaseAlarmCommentServiceTest extends AbstractServiceTest {
@After
public void after() {
alarmService.deleteAlarm(tenantId, alarm.getId());
tenantService.deleteTenant(tenantId);
}

44
dao/src/test/java/org/thingsboard/server/dao/service/BaseAlarmServiceTest.java

@ -16,14 +16,12 @@
package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.alarm.Alarm;
import org.thingsboard.server.common.data.alarm.AlarmCreateOrUpdateActiveRequest;
@ -36,9 +34,7 @@ import org.thingsboard.server.common.data.alarm.AlarmStatus;
import org.thingsboard.server.common.data.alarm.AlarmUpdateRequest;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.id.AssetId;
import org.thingsboard.server.common.data.id.TenantId;
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.common.data.page.TimePageLink;
import org.thingsboard.server.common.data.query.AlarmData;
@ -52,7 +48,12 @@ import org.thingsboard.server.common.data.relation.EntityRelation;
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
import org.thingsboard.server.common.data.security.Authority;
import org.thingsboard.server.dao.alarm.AlarmApiCallResult;
import org.thingsboard.server.dao.alarm.AlarmOperationResult;
import org.thingsboard.server.dao.alarm.AlarmService;
import org.thingsboard.server.dao.asset.AssetService;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.relation.RelationService;
import org.thingsboard.server.dao.user.UserService;
import java.util.Arrays;
import java.util.Collections;
@ -61,29 +62,24 @@ import java.util.concurrent.ExecutionException;
public abstract class BaseAlarmServiceTest extends AbstractServiceTest {
public static final String TEST_ALARM = "TEST_ALARM";
@Autowired
AlarmService alarmService;
@Autowired
AssetService assetService;
@Autowired
CustomerService customerService;
@Autowired
DeviceService deviceService;
@Autowired
RelationService relationService;
@Autowired
UserService userService;
public static final String TEST_ALARM = "TEST_ALARM";
private static final String TEST_TENANT_EMAIL = "testtenant@thingsboard.org";
private static final String TEST_TENANT_FIRST_NAME = "testtenantfirstname";
private static final String TEST_TENANT_LAST_NAME = "testtenantlastname";
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
@Test
public void testSaveAndFetchAlarm() throws ExecutionException, InterruptedException {
AssetId parentId = new AssetId(Uuids.timeBased());

23
dao/src/test/java/org/thingsboard/server/dao/service/BaseApiUsageStateServiceTest.java

@ -15,33 +15,18 @@
*/
package org.thingsboard.server.dao.service;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.ApiUsageStateValue;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.ApiUsageState;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.dao.usagerecord.ApiUsageStateService;
public abstract class BaseApiUsageStateServiceTest extends AbstractServiceTest {
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
@Autowired
ApiUsageStateService apiUsageStateService;
@Test
public void testFindApiUsageStateByTenantId() {

26
dao/src/test/java/org/thingsboard/server/dao/service/BaseAssetProfileServiceTest.java

@ -19,19 +19,18 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.ThingsBoardThreadFactory;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.asset.AssetProfile;
import org.thingsboard.server.common.data.asset.AssetProfileInfo;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.dao.asset.AssetProfileService;
import org.thingsboard.server.dao.asset.AssetService;
import org.thingsboard.server.dao.exception.DataValidationException;
import java.util.ArrayList;
@ -46,21 +45,10 @@ public abstract class BaseAssetProfileServiceTest extends AbstractServiceTest {
private IdComparator<AssetProfile> idComparator = new IdComparator<>();
private IdComparator<AssetProfileInfo> assetProfileInfoIdComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
@Autowired
AssetProfileService assetProfileService;
@Autowired
AssetService assetService;
@Test
public void testSaveAssetProfile() {

42
dao/src/test/java/org/thingsboard/server/dao/service/BaseAssetServiceTest.java

@ -16,11 +16,10 @@
package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.EntitySubtype;
import org.thingsboard.server.common.data.StringUtils;
@ -31,6 +30,8 @@ import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.dao.asset.AssetService;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.exception.DataValidationException;
import java.util.ArrayList;
@ -41,23 +42,12 @@ import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
public abstract class BaseAssetServiceTest extends AbstractServiceTest {
private IdComparator<Asset> idComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@Autowired
AssetService assetService;
@Autowired
CustomerService customerService;
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
private IdComparator<Asset> idComparator = new IdComparator<>();
@Test
public void testSaveAsset() {
@ -220,12 +210,6 @@ public abstract class BaseAssetServiceTest extends AbstractServiceTest {
@Test
public void testFindAssetsByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<Asset> assets = new ArrayList<>();
for (int i=0;i<178;i++) {
Asset asset = new Asset();
@ -257,8 +241,6 @@ public abstract class BaseAssetServiceTest extends AbstractServiceTest {
pageData = assetService.findAssetsByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test
@ -419,12 +401,6 @@ public abstract class BaseAssetServiceTest extends AbstractServiceTest {
@Test
public void testFindAssetsByTenantIdAndCustomerId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
Customer customer = new Customer();
customer.setTitle("Test customer");
customer.setTenantId(tenantId);
@ -463,8 +439,6 @@ public abstract class BaseAssetServiceTest extends AbstractServiceTest {
pageData = assetService.findAssetInfosByTenantIdAndCustomerId(tenantId, customerId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test

25
dao/src/test/java/org/thingsboard/server/dao/service/BaseCustomerServiceTest.java

@ -25,6 +25,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.ThingsBoardExecutors;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.StringUtils;
@ -32,6 +33,7 @@ import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.exception.DataValidationException;
import java.util.ArrayList;
@ -41,28 +43,22 @@ import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
public abstract class BaseCustomerServiceTest extends AbstractServiceTest {
@Autowired
CustomerService customerService;
static final int TIMEOUT = 30;
ListeningExecutorService executor;
private TenantId tenantId;
@Before
public void before() {
executor = MoreExecutors.listeningDecorator(ThingsBoardExecutors.newWorkStealingPool(8, getClass()));
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
}
@After
public void after() {
executor.shutdownNow();
tenantService.deleteTenant(tenantId);
}
@Test
@ -152,11 +148,6 @@ public abstract class BaseCustomerServiceTest extends AbstractServiceTest {
@Test
public void testFindCustomersByTenantId() throws Exception {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<ListenableFuture<Customer>> futures = new ArrayList<>(135);
for (int i = 0; i < 135; i++) {
@ -187,8 +178,6 @@ public abstract class BaseCustomerServiceTest extends AbstractServiceTest {
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test

53
dao/src/test/java/org/thingsboard/server/dao/service/BaseDashboardServiceTest.java

@ -16,11 +16,10 @@
package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.Dashboard;
import org.thingsboard.server.common.data.DashboardInfo;
@ -33,6 +32,9 @@ import org.thingsboard.server.common.data.id.TenantId;
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.customer.CustomerService;
import org.thingsboard.server.dao.dashboard.DashboardService;
import org.thingsboard.server.dao.edge.EdgeService;
import org.thingsboard.server.dao.exception.DataValidationException;
import java.io.IOException;
@ -42,24 +44,15 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
public abstract class BaseDashboardServiceTest extends AbstractServiceTest {
private IdComparator<DashboardInfo> idComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@Autowired
CustomerService customerService;
@Autowired
DashboardService dashboardService;
@Autowired
EdgeService edgeService;
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
private IdComparator<DashboardInfo> idComparator = new IdComparator<>();
@Test
public void testSaveDashboard() throws IOException {
@ -176,12 +169,6 @@ public abstract class BaseDashboardServiceTest extends AbstractServiceTest {
@Test
public void testFindDashboardsByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<DashboardInfo> dashboards = new ArrayList<>();
for (int i=0;i<165;i++) {
Dashboard dashboard = new Dashboard();
@ -212,18 +199,10 @@ public abstract class BaseDashboardServiceTest extends AbstractServiceTest {
pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test
public void testFindMobileDashboardsByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<DashboardInfo> mobileDashboards = new ArrayList<>();
for (int i=0;i<165;i++) {
Dashboard dashboard = new Dashboard();
@ -272,8 +251,6 @@ public abstract class BaseDashboardServiceTest extends AbstractServiceTest {
pageData = dashboardService.findMobileDashboardsByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test
@ -353,12 +330,6 @@ public abstract class BaseDashboardServiceTest extends AbstractServiceTest {
@Test
public void testFindDashboardsByTenantIdAndCustomerId() throws ExecutionException, InterruptedException {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
Customer customer = new Customer();
customer.setTitle("Test customer");
customer.setTenantId(tenantId);
@ -396,8 +367,6 @@ public abstract class BaseDashboardServiceTest extends AbstractServiceTest {
pageData = dashboardService.findDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test

26
dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceCredentialsServiceTest.java

@ -16,37 +16,25 @@
package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.id.DeviceCredentialsId;
import org.thingsboard.server.common.data.id.DeviceId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.security.DeviceCredentials;
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
import org.thingsboard.server.dao.device.DeviceCredentialsService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.exception.DataValidationException;
public abstract class BaseDeviceCredentialsServiceTest extends AbstractServiceTest {
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
@Autowired
DeviceCredentialsService deviceCredentialsService;
@Autowired
DeviceService deviceService;
@Test
public void testCreateDeviceCredentials() {

32
dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceProfileServiceTest.java

@ -19,24 +19,24 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.ThingsBoardThreadFactory;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.DeviceProfileInfo;
import org.thingsboard.server.common.data.DeviceTransportType;
import org.thingsboard.server.common.data.OtaPackage;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.dao.device.DeviceProfileService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.ota.OtaPackageService;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@ -44,7 +44,6 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
@ -52,25 +51,16 @@ import static org.thingsboard.server.common.data.ota.OtaPackageType.FIRMWARE;
public abstract class BaseDeviceProfileServiceTest extends AbstractServiceTest {
@Autowired
DeviceProfileService deviceProfileService;
@Autowired
DeviceService deviceService;
@Autowired
OtaPackageService otaPackageService;
private IdComparator<DeviceProfile> idComparator = new IdComparator<>();
private IdComparator<DeviceProfileInfo> deviceProfileInfoIdComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
@Test
public void testSaveDeviceProfile() {
DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile");

39
dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceServiceTest.java

@ -21,6 +21,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.DeviceInfo;
@ -38,7 +39,13 @@ import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.security.DeviceCredentials;
import org.thingsboard.server.common.data.security.DeviceCredentialsType;
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.device.DeviceCredentialsService;
import org.thingsboard.server.dao.device.DeviceProfileService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.ota.OtaPackageService;
import org.thingsboard.server.dao.tenant.TenantProfileService;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@ -51,14 +58,24 @@ import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
private IdComparator<Device> idComparator = new IdComparator<>();
@Autowired
CustomerService customerService;
@Autowired
DeviceCredentialsService deviceCredentialsService;
@Autowired
DeviceProfileService deviceProfileService;
@Autowired
DeviceService deviceService;
@Autowired
OtaPackageService otaPackageService;
@Autowired
TenantProfileService tenantProfileService;
private TenantId tenantId;
private IdComparator<Device> idComparator = new IdComparator<>();
private TenantId anotherTenantId;
@Before
public void before() {
tenantId = createTenant();
anotherTenantId = createTenant();
}
@ -384,12 +401,6 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
@Test
public void testFindDevicesByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<Device> devices = new ArrayList<>();
for (int i = 0; i < 178; i++) {
Device device = new Device();
@ -421,8 +432,6 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
pageData = deviceService.findDevicesByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test
@ -583,12 +592,6 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
@Test
public void testFindDevicesByTenantIdAndCustomerId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
Customer customer = new Customer();
customer.setTitle("Test customer");
customer.setTenantId(tenantId);
@ -627,8 +630,6 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest {
pageData = deviceService.findDeviceInfosByTenantIdAndCustomerId(tenantId, customerId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test

9
dao/src/test/java/org/thingsboard/server/dao/service/BaseEdgeEventServiceTest.java

@ -21,6 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.edge.EdgeEvent;
import org.thingsboard.server.common.data.edge.EdgeEventActionType;
import org.thingsboard.server.common.data.edge.EdgeEventType;
@ -32,20 +33,20 @@ import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.SortOrder;
import org.thingsboard.server.common.data.page.TimePageLink;
import org.thingsboard.server.dao.edge.EdgeEventService;
import java.io.IOException;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT;
public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest {
@Autowired
EdgeEventService edgeEventService;
long timeBeforeStartTime;
long startTime;
long eventTime;

45
dao/src/test/java/org/thingsboard/server/dao/service/BaseEdgeServiceTest.java

@ -17,11 +17,10 @@ package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.EntitySubtype;
@ -36,7 +35,10 @@ import org.thingsboard.server.common.data.rule.RuleChain;
import org.thingsboard.server.common.data.rule.RuleChainMetaData;
import org.thingsboard.server.common.data.rule.RuleChainType;
import org.thingsboard.server.common.data.rule.RuleNode;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.edge.EdgeService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.rule.RuleChainService;
import java.util.ArrayList;
import java.util.Arrays;
@ -47,23 +49,14 @@ import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
public abstract class BaseEdgeServiceTest extends AbstractServiceTest {
private IdComparator<Edge> idComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@Autowired
CustomerService customerService;
@Autowired
EdgeService edgeService;
@Autowired
RuleChainService ruleChainService;
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
private IdComparator<Edge> idComparator = new IdComparator<>();
@Test
public void testSaveEdge() {
@ -204,12 +197,6 @@ public abstract class BaseEdgeServiceTest extends AbstractServiceTest {
@Test
public void testFindEdgesByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<Edge> edges = new ArrayList<>();
for (int i = 0; i < 178; i++) {
Edge edge = constructEdge(tenantId, "Edge " + i, "default");
@ -238,8 +225,6 @@ public abstract class BaseEdgeServiceTest extends AbstractServiceTest {
pageData = edgeService.findEdgesByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test
@ -388,12 +373,6 @@ public abstract class BaseEdgeServiceTest extends AbstractServiceTest {
@Test
public void testFindEdgesByTenantIdAndCustomerId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
Customer customer = new Customer();
customer.setTitle("Test customer");
customer.setTenantId(tenantId);
@ -429,8 +408,6 @@ public abstract class BaseEdgeServiceTest extends AbstractServiceTest {
pageData = edgeService.findEdgesByTenantIdAndCustomerId(tenantId, customerId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test

2
dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceRegistryTest.java

@ -28,7 +28,7 @@ import org.thingsboard.server.dao.rule.RuleChainService;
public abstract class BaseEntityServiceRegistryTest extends AbstractServiceTest {
@Autowired
private EntityServiceRegistry entityServiceRegistry;
EntityServiceRegistry entityServiceRegistry;
@Test
public void givenAllEntityTypes_whenGetServiceByEntityTypeCalled_thenAllBeansExists() {

43
dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceTest.java

@ -21,9 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.ResultSetExtractor;
@ -31,7 +29,6 @@ import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.edge.Edge;
import org.thingsboard.server.common.data.id.CustomerId;
@ -73,8 +70,13 @@ import org.thingsboard.server.common.data.relation.EntityRelation;
import org.thingsboard.server.common.data.relation.EntitySearchDirection;
import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter;
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
import org.thingsboard.server.dao.asset.AssetService;
import org.thingsboard.server.dao.attributes.AttributesService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.edge.EdgeService;
import org.thingsboard.server.dao.entity.EntityService;
import org.thingsboard.server.dao.model.sqlts.ts.TsKvEntity;
import org.thingsboard.server.dao.relation.RelationService;
import org.thingsboard.server.dao.sql.relation.RelationRepository;
import org.thingsboard.server.dao.timeseries.TimeseriesService;
@ -100,30 +102,21 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest {
static final int ENTITY_COUNT = 5;
@Autowired
private AttributesService attributesService;
AssetService assetService;
@Autowired
private TimeseriesService timeseriesService;
private TenantId tenantId;
AttributesService attributesService;
@Autowired
private RelationRepository relationRepository;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
DeviceService deviceService;
@Autowired
EdgeService edgeService;
@Autowired
EntityService entityService;
@Autowired
RelationRepository relationRepository;
@Autowired
RelationService relationService;
@Autowired
TimeseriesService timeseriesService;
@Test
public void testCountEntitiesByQuery() throws InterruptedException {

23
dao/src/test/java/org/thingsboard/server/dao/service/BaseOtaPackageServiceTest.java

@ -20,13 +20,13 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.OtaPackage;
import org.thingsboard.server.common.data.OtaPackageInfo;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.TenantProfile;
import org.thingsboard.server.common.data.id.DeviceProfileId;
import org.thingsboard.server.common.data.id.TenantId;
@ -34,7 +34,11 @@ import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
import org.thingsboard.server.dao.device.DeviceProfileService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.ota.OtaPackageService;
import org.thingsboard.server.dao.tenant.TenantProfileService;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@ -59,18 +63,19 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest {
private final IdComparator<OtaPackageInfo> idComparator = new IdComparator<>();
private TenantId tenantId;
private DeviceProfileId deviceProfileId;
@Autowired
DeviceProfileService deviceProfileService;
@Autowired
DeviceService deviceService;
@Autowired
OtaPackageService otaPackageService;
@Autowired
TenantProfileService tenantProfileService;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile");
DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
Assert.assertNotNull(savedDeviceProfile);

10
dao/src/test/java/org/thingsboard/server/dao/service/BaseQueueServiceTest.java

@ -20,6 +20,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.TenantProfile;
@ -35,6 +36,8 @@ import org.thingsboard.server.common.data.queue.SubmitStrategyType;
import org.thingsboard.server.common.data.tenant.profile.TenantProfileData;
import org.thingsboard.server.common.data.tenant.profile.TenantProfileQueueConfiguration;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.queue.QueueService;
import org.thingsboard.server.dao.tenant.TenantProfileService;
import java.util.ArrayList;
import java.util.Collections;
@ -42,6 +45,11 @@ import java.util.List;
public abstract class BaseQueueServiceTest extends AbstractServiceTest {
@Autowired
TenantProfileService tenantProfileService;
@Autowired
QueueService queueService;
private IdComparator<Queue> idComparator = new IdComparator<>();
private TenantId tenantId;
@ -83,7 +91,7 @@ public abstract class BaseQueueServiceTest extends AbstractServiceTest {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
tenant.setTenantProfileId(tenantProfileId);
tenant.setTenantProfileId(tenantProfileId); //custom profile
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();

5
dao/src/test/java/org/thingsboard/server/dao/service/BaseRelationServiceTest.java

@ -23,6 +23,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.id.AssetId;
import org.thingsboard.server.common.data.id.DeviceId;
@ -33,6 +34,7 @@ import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter;
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
import org.thingsboard.server.common.data.relation.RelationsSearchParameters;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.relation.RelationService;
import java.util.ArrayList;
import java.util.Collections;
@ -42,6 +44,9 @@ import java.util.concurrent.ExecutionException;
public abstract class BaseRelationServiceTest extends AbstractServiceTest {
@Autowired
RelationService relationService;
@Before
public void before() {
}

34
dao/src/test/java/org/thingsboard/server/dao/service/BaseRuleChainServiceTest.java

@ -17,11 +17,10 @@ package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.edge.Edge;
@ -34,7 +33,9 @@ import org.thingsboard.server.common.data.rule.RuleChain;
import org.thingsboard.server.common.data.rule.RuleChainMetaData;
import org.thingsboard.server.common.data.rule.RuleChainType;
import org.thingsboard.server.common.data.rule.RuleNode;
import org.thingsboard.server.dao.edge.EdgeService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.rule.RuleChainService;
import java.io.IOException;
import java.util.ArrayList;
@ -46,25 +47,14 @@ import java.util.List;
*/
public abstract class BaseRuleChainServiceTest extends AbstractServiceTest {
@Autowired
EdgeService edgeService;
@Autowired
RuleChainService ruleChainService;
private IdComparator<RuleChain> idComparator = new IdComparator<>();
private IdComparator<RuleNode> ruleNodeIdComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
@Test
public void testSaveRuleChain() throws IOException {
RuleChain ruleChain = new RuleChain();
@ -133,12 +123,6 @@ public abstract class BaseRuleChainServiceTest extends AbstractServiceTest {
@Test
public void testFindRuleChainsByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<RuleChain> ruleChains = new ArrayList<>();
for (int i = 0; i < 165; i++) {
RuleChain ruleChain = new RuleChain();
@ -169,8 +153,6 @@ public abstract class BaseRuleChainServiceTest extends AbstractServiceTest {
pageData = ruleChainService.findTenantRuleChainsByType(tenantId, RuleChainType.CORE, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test

14
dao/src/test/java/org/thingsboard/server/dao/service/BaseTenantProfileServiceTest.java

@ -18,8 +18,10 @@ package org.thingsboard.server.dao.service;
import com.fasterxml.jackson.databind.node.NullNode;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.EntityInfo;
import org.thingsboard.server.common.data.Tenant;
@ -36,6 +38,7 @@ import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileCon
import org.thingsboard.server.common.data.tenant.profile.TenantProfileData;
import org.thingsboard.server.common.data.tenant.profile.TenantProfileQueueConfiguration;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.tenant.TenantProfileService;
import java.util.ArrayList;
import java.util.Collections;
@ -44,9 +47,20 @@ import java.util.stream.Collectors;
public abstract class BaseTenantProfileServiceTest extends AbstractServiceTest {
@Autowired
TenantProfileService tenantProfileService;
private IdComparator<TenantProfile> idComparator = new IdComparator<>();
private IdComparator<EntityInfo> tenantProfileInfoIdComparator = new IdComparator<>();
@Before
public void before() {
//this test requires no Tenants in the database
tenantId = null;
tenantService.deleteTenants();
tenantProfileService.deleteTenantProfiles(TenantId.SYS_TENANT_ID);
}
@After
public void after() {
tenantProfileService.deleteTenantProfiles(TenantId.SYS_TENANT_ID);

78
dao/src/test/java/org/thingsboard/server/dao/service/BaseTenantServiceTest.java

@ -23,24 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.cache.TbTransactionalCache;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.Dashboard;
import org.thingsboard.server.common.data.DashboardInfo;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.DeviceProfileType;
import org.thingsboard.server.common.data.DeviceTransportType;
import org.thingsboard.server.common.data.EntityView;
import org.thingsboard.server.common.data.OtaPackage;
import org.thingsboard.server.common.data.OtaPackageInfo;
import org.thingsboard.server.common.data.ResourceType;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.TbResource;
import org.thingsboard.server.common.data.TbResourceInfo;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.TenantInfo;
import org.thingsboard.server.common.data.TenantProfile;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.*;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.device.profile.DeviceProfileData;
import org.thingsboard.server.common.data.device.profile.MqttDeviceProfileTransportConfiguration;
@ -54,8 +37,23 @@ import org.thingsboard.server.common.data.rule.RuleChain;
import org.thingsboard.server.common.data.rule.RuleChainType;
import org.thingsboard.server.common.data.security.Authority;
import org.thingsboard.server.common.data.widget.WidgetsBundle;
import org.thingsboard.server.dao.asset.AssetService;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.dashboard.DashboardService;
import org.thingsboard.server.dao.device.DeviceProfileService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.edge.EdgeService;
import org.thingsboard.server.dao.entityview.EntityViewService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.ota.OtaPackageService;
import org.thingsboard.server.dao.resource.ResourceService;
import org.thingsboard.server.dao.rpc.RpcService;
import org.thingsboard.server.dao.rule.RuleChainService;
import org.thingsboard.server.dao.tenant.TenantDao;
import org.thingsboard.server.dao.tenant.TenantProfileService;
import org.thingsboard.server.dao.usagerecord.ApiUsageStateService;
import org.thingsboard.server.dao.user.UserService;
import org.thingsboard.server.dao.widget.WidgetsBundleService;
import java.util.ArrayList;
import java.util.Collections;
@ -69,16 +67,45 @@ import static org.mockito.Mockito.verify;
public abstract class BaseTenantServiceTest extends AbstractServiceTest {
private IdComparator<Tenant> idComparator = new IdComparator<>();
@SpyBean
protected TenantDao tenantDao;
TenantDao tenantDao;
@Autowired
protected TbTransactionalCache<TenantId, Tenant> cache;
ApiUsageStateService apiUsageStateService;
@Autowired
AssetService assetService;
@Autowired
CustomerService customerService;
@Autowired
DashboardService dashboardService;
@Autowired
DeviceProfileService deviceProfileService;
@Autowired
DeviceService deviceService;
@Autowired
EdgeService edgeService;
@Autowired
EntityViewService entityViewService;
@Autowired
OtaPackageService otaPackageService;
@Autowired
protected TbTransactionalCache<TenantId, Boolean> existsTenantCache;
ResourceService resourceService;
@Autowired
RpcService rpcService;
@Autowired
RuleChainService ruleChainService;
@Autowired
TbTransactionalCache<TenantId, Boolean> existsTenantCache;
@Autowired
TbTransactionalCache<TenantId, Tenant> cache;
@Autowired
TenantProfileService tenantProfileService;
@Autowired
UserService userService;
@Autowired
WidgetsBundleService widgetsBundleService;
private final IdComparator<Tenant> idComparator = new IdComparator<>();
@Test
public void testSaveTenant() {
@ -150,6 +177,7 @@ public abstract class BaseTenantServiceTest extends AbstractServiceTest {
@Test
public void testFindTenants() {
tenantService.deleteTenants();
List<Tenant> tenants = new ArrayList<>();
PageLink pageLink = new PageLink(17);
PageData<Tenant> pageData = tenantService.findTenants(pageLink);
@ -264,7 +292,7 @@ public abstract class BaseTenantServiceTest extends AbstractServiceTest {
@Test
public void testFindTenantInfos() {
tenantService.deleteTenants();
List<TenantInfo> tenants = new ArrayList<>();
PageLink pageLink = new PageLink(17);
PageData<TenantInfo> pageData = tenantService.findTenantInfos(pageLink);

57
dao/src/test/java/org/thingsboard/server/dao/service/BaseUserServiceTest.java

@ -15,11 +15,11 @@
*/
package org.thingsboard.server.dao.service;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.StringUtils;
@ -33,7 +33,9 @@ import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.security.Authority;
import org.thingsboard.server.common.data.security.UserCredentials;
import org.thingsboard.server.common.data.security.UserSettings;
import org.thingsboard.server.dao.customer.CustomerService;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.user.UserService;
import java.util.ArrayList;
import java.util.Collections;
@ -41,19 +43,17 @@ import java.util.List;
public abstract class BaseUserServiceTest extends AbstractServiceTest {
@Autowired
CustomerService customerService;
@Autowired
UserService userService;
private IdComparator<User> idComparator = new IdComparator<>();
private TenantId tenantId;
private UserSettings userSettings;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
User tenantAdmin = new User();
tenantAdmin.setAuthority(Authority.TENANT_ADMIN);
tenantAdmin.setTenantId(tenantId);
@ -75,11 +75,6 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
userSettings = createUserSettings(customerUser.getId());
}
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
@Test
public void testFindUserByEmail() {
User user = userService.findUserByEmail(SYSTEM_TENANT_ID, "sysadmin@thingsboard.org");
@ -209,17 +204,13 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
Assert.assertEquals(1, users.size());
Assert.assertEquals(tenantAdminUser, users.get(0));
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
TenantId secondTenantId = createTenant();
List<User> tenantAdmins = new ArrayList<>();
for (int i = 0; i < 124; i++) {
User user = new User();
user.setAuthority(Authority.TENANT_ADMIN);
user.setTenantId(tenantId);
user.setTenantId(secondTenantId);
user.setEmail("testTenant" + i + "@thingsboard.org");
tenantAdmins.add(userService.saveUser(user));
}
@ -227,7 +218,7 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
List<User> loadedTenantAdmins = new ArrayList<>();
PageLink pageLink = new PageLink(33);
do {
pageData = userService.findTenantAdmins(tenantId, pageLink);
pageData = userService.findTenantAdmins(secondTenantId, pageLink);
loadedTenantAdmins.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageLink.nextPageLink();
@ -239,10 +230,10 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
Assert.assertEquals(tenantAdmins, loadedTenantAdmins);
tenantService.deleteTenant(tenantId);
tenantService.deleteTenant(secondTenantId);
pageLink = new PageLink(33);
pageData = userService.findTenantAdmins(tenantId, pageLink);
pageData = userService.findTenantAdmins(secondTenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
@ -250,12 +241,6 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
@Test
public void testFindTenantAdminsByEmail() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
String email1 = "testEmail1";
List<User> tenantAdminsEmail1 = new ArrayList<>();
@ -332,8 +317,6 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
pageData = userService.findTenantAdmins(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(0, pageData.getData().size());
tenantService.deleteTenant(tenantId);
}
@Test
@ -346,12 +329,6 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
Assert.assertEquals(1, users.size());
Assert.assertEquals(customerUser, users.get(0));
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
Customer customer = new Customer();
customer.setTitle("Test customer");
customer.setTenantId(tenantId);
@ -394,12 +371,6 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
@Test
public void testFindCustomerUsersByEmail() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
Customer customer = new Customer();
customer.setTitle("Test customer");
customer.setTenantId(tenantId);
@ -485,8 +456,6 @@ public abstract class BaseUserServiceTest extends AbstractServiceTest {
pageData = userService.findCustomerUsers(tenantId, customerId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(0, pageData.getData().size());
tenantService.deleteTenant(tenantId);
}
private UserSettings createUserSettings(UserId userId) {

27
dao/src/test/java/org/thingsboard/server/dao/service/BaseWidgetTypeServiceTest.java

@ -18,18 +18,18 @@ package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.thingsboard.server.common.data.Tenant;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.widget.WidgetType;
import org.thingsboard.server.common.data.widget.WidgetTypeDetails;
import org.thingsboard.server.common.data.widget.WidgetsBundle;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.model.ModelConstants;
import org.thingsboard.server.dao.widget.WidgetTypeService;
import org.thingsboard.server.dao.widget.WidgetsBundleService;
import java.io.IOException;
import java.util.ArrayList;
@ -38,23 +38,12 @@ import java.util.List;
public abstract class BaseWidgetTypeServiceTest extends AbstractServiceTest {
private IdComparator<WidgetType> idComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@Autowired
WidgetsBundleService widgetsBundleService;
@Autowired
WidgetTypeService widgetTypeService;
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
private IdComparator<WidgetType> idComparator = new IdComparator<>();
@Test
public void testSaveWidgetType() throws IOException {

44
dao/src/test/java/org/thingsboard/server/dao/service/BaseWidgetsBundleServiceTest.java

@ -16,18 +16,17 @@
package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.thingsboard.server.common.data.Tenant;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.widget.WidgetsBundle;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.model.ModelConstants;
import org.thingsboard.server.dao.widget.WidgetsBundleService;
import java.io.IOException;
import java.util.ArrayList;
@ -36,23 +35,10 @@ import java.util.List;
public abstract class BaseWidgetsBundleServiceTest extends AbstractServiceTest {
private IdComparator<WidgetsBundle> idComparator = new IdComparator<>();
private TenantId tenantId;
@Before
public void before() {
Tenant tenant = new Tenant();
tenant.setTitle("My tenant");
Tenant savedTenant = tenantService.saveTenant(tenant);
Assert.assertNotNull(savedTenant);
tenantId = savedTenant.getId();
}
@Autowired
WidgetsBundleService widgetsBundleService;
@After
public void after() {
tenantService.deleteTenant(tenantId);
}
private IdComparator<WidgetsBundle> idComparator = new IdComparator<>();
@Test
public void testSaveWidgetsBundle() throws IOException {
@ -249,11 +235,6 @@ public abstract class BaseWidgetsBundleServiceTest extends AbstractServiceTest {
@Test
public void testFindTenantWidgetsBundlesByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
List<WidgetsBundle> widgetsBundles = new ArrayList<>();
for (int i=0;i<127;i++) {
@ -286,7 +267,6 @@ public abstract class BaseWidgetsBundleServiceTest extends AbstractServiceTest {
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
@Test
@ -294,11 +274,6 @@ public abstract class BaseWidgetsBundleServiceTest extends AbstractServiceTest {
List<WidgetsBundle> systemWidgetsBundles = widgetsBundleService.findSystemWidgetsBundles(tenantId);
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
TenantId systemTenantId = TenantId.fromUUID(ModelConstants.NULL_UUID);
List<WidgetsBundle> createdWidgetsBundles = new ArrayList<>();
@ -371,8 +346,6 @@ public abstract class BaseWidgetsBundleServiceTest extends AbstractServiceTest {
Collections.sort(loadedWidgetsBundles, idComparator);
Assert.assertEquals(systemWidgetsBundles, loadedWidgetsBundles);
tenantService.deleteTenant(tenantId);
}
@Test
@ -380,11 +353,6 @@ public abstract class BaseWidgetsBundleServiceTest extends AbstractServiceTest {
List<WidgetsBundle> systemWidgetsBundles = widgetsBundleService.findSystemWidgetsBundles(tenantId);
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
TenantId tenantId = tenant.getId();
TenantId systemTenantId = TenantId.fromUUID(ModelConstants.NULL_UUID);
List<WidgetsBundle> createdWidgetsBundles = new ArrayList<>();
@ -432,8 +400,6 @@ public abstract class BaseWidgetsBundleServiceTest extends AbstractServiceTest {
Collections.sort(loadedWidgetsBundles, idComparator);
Assert.assertEquals(systemWidgetsBundles, loadedWidgetsBundles);
tenantService.deleteTenant(tenantId);
}
}

6
dao/src/test/java/org/thingsboard/server/dao/service/event/BaseEventServiceTest.java

@ -19,6 +19,7 @@ import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.EventInfo;
import org.thingsboard.server.common.data.event.Event;
import org.thingsboard.server.common.data.event.EventType;
@ -31,6 +32,7 @@ import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.SortOrder;
import org.thingsboard.server.common.data.page.TimePageLink;
import org.thingsboard.server.dao.event.EventService;
import org.thingsboard.server.dao.service.AbstractServiceTest;
import java.text.ParseException;
@ -39,6 +41,10 @@ import java.util.List;
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT;
public abstract class BaseEventServiceTest extends AbstractServiceTest {
@Autowired
EventService eventService;
long timeBeforeStartTime;
long startTime;
long eventTime;

10
dao/src/test/java/org/thingsboard/server/dao/service/timeseries/BaseTimeseriesServiceTest.java

@ -21,6 +21,7 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.EntityView;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.id.DeviceId;
@ -39,7 +40,9 @@ import org.thingsboard.server.common.data.kv.ReadTsKvQueryResult;
import org.thingsboard.server.common.data.kv.StringDataEntry;
import org.thingsboard.server.common.data.kv.TsKvEntry;
import org.thingsboard.server.common.data.objects.TelemetryEntityView;
import org.thingsboard.server.dao.entityview.EntityViewService;
import org.thingsboard.server.dao.service.AbstractServiceTest;
import org.thingsboard.server.dao.timeseries.TimeseriesService;
import java.util.ArrayList;
import java.util.Arrays;
@ -59,6 +62,13 @@ import static org.junit.Assert.assertNotNull;
@Slf4j
public abstract class BaseTimeseriesServiceTest extends AbstractServiceTest {
@Autowired
TimeseriesService tsService;
@Autowired
EntityViewService entityViewService;
static final int MAX_TIMEOUT = 30;
private static final String STRING_KEY = "stringKey";

Loading…
Cancel
Save