use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class UserEntity method toData.
@Override
public User toData() {
User user = new User(new UserId(getId()));
user.setCreatedTime(UUIDs.unixTimestamp(getId()));
user.setAuthority(authority);
if (tenantId != null) {
user.setTenantId(new TenantId(fromString(tenantId)));
}
if (customerId != null) {
user.setCustomerId(new CustomerId(fromString(customerId)));
}
user.setEmail(email);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setAdditionalInfo(additionalInfo);
return user;
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class BaseCustomerServiceTest method testSaveCustomerWithInvalidTenant.
@Test(expected = DataValidationException.class)
public void testSaveCustomerWithInvalidTenant() {
Customer customer = new Customer();
customer.setTitle("My customer");
customer.setTenantId(new TenantId(UUIDs.timeBased()));
customerService.saveCustomer(customer);
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class BaseDashboardServiceTest method testSaveDashboardWithInvalidTenant.
@Test(expected = DataValidationException.class)
public void testSaveDashboardWithInvalidTenant() {
Dashboard dashboard = new Dashboard();
dashboard.setTitle("My dashboard");
dashboard.setTenantId(new TenantId(UUIDs.timeBased()));
dashboardService.saveDashboard(dashboard);
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class BaseDashboardServiceTest method testFindDashboardsByTenantId.
@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();
dashboard.setTenantId(tenantId);
dashboard.setTitle("Dashboard" + i);
dashboards.add(new DashboardInfo(dashboardService.saveDashboard(dashboard)));
}
List<DashboardInfo> loadedDashboards = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(16);
TextPageData<DashboardInfo> pageData = null;
do {
pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink);
loadedDashboards.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(dashboards, idComparator);
Collections.sort(loadedDashboards, idComparator);
Assert.assertEquals(dashboards, loadedDashboards);
dashboardService.deleteDashboardsByTenantId(tenantId);
pageLink = new TextPageLink(31);
pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
tenantService.deleteTenant(tenantId);
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class BaseDeviceServiceTest method testSaveDeviceWithInvalidTenant.
@Test(expected = DataValidationException.class)
public void testSaveDeviceWithInvalidTenant() {
Device device = new Device();
device.setName("My device");
device.setType("default");
device.setTenantId(new TenantId(UUIDs.timeBased()));
deviceService.saveDevice(device);
}
Aggregations