use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class JpaBasePluginDaoTest method createPlugin.
private void createPlugin(UUID tenantId, String namePrefix, int i) {
PluginMetaData plugin = new PluginMetaData();
plugin.setId(new PluginId(UUIDs.timeBased()));
plugin.setTenantId(new TenantId(tenantId));
plugin.setName(namePrefix + i);
pluginDao.save(plugin);
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class JpaBaseRuleDaoTest method testFindByTenantIdAndPageLink.
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindByTenantIdAndPageLink() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
createRulesTwoTenants(tenantId1, tenantId2, "name_", "token");
List<RuleMetaData> rules1 = ruleDao.findByTenantIdAndPageLink(new TenantId(tenantId1), new TextPageLink(20, "name_"));
assertEquals(20, rules1.size());
List<RuleMetaData> rules2 = ruleDao.findByTenantIdAndPageLink(new TenantId(tenantId1), new TextPageLink(20, "name_", rules1.get(19).getId().getId(), null));
assertEquals(10, rules2.size());
List<RuleMetaData> rules3 = ruleDao.findByTenantIdAndPageLink(new TenantId(tenantId1), new TextPageLink(20, "name_", rules2.get(9).getId().getId(), null));
assertEquals(0, rules3.size());
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class JpaBaseRuleDaoTest method createRule.
private void createRule(UUID tenantId, String namePrefix, String pluginToken, int i) {
RuleMetaData ruleMetaData = new RuleMetaData();
ruleMetaData.setId(new RuleId(UUIDs.timeBased()));
ruleMetaData.setTenantId(new TenantId(tenantId));
ruleMetaData.setName(namePrefix + i);
ruleMetaData.setPluginToken(pluginToken);
ruleDao.save(ruleMetaData);
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class JpaTenantDaoTest method createTenant.
private void createTenant(String region, String title, int index) {
Tenant tenant = new Tenant();
tenant.setId(new TenantId(UUIDs.timeBased()));
tenant.setRegion(region);
tenant.setTitle(title + "_" + index);
tenantDao.save(tenant);
}
use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.
the class BaseUserServiceTest method testFindCustomerUsers.
@Test
public void testFindCustomerUsers() {
User customerUser = userService.findUserByEmail("customer@thingsboard.org");
TextPageData<User> pageData = userService.findCustomerUsers(customerUser.getTenantId(), customerUser.getCustomerId(), new TextPageLink(10));
Assert.assertFalse(pageData.hasNext());
List<User> users = pageData.getData();
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);
customer = customerService.saveCustomer(customer);
CustomerId customerId = customer.getId();
List<User> customerUsers = new ArrayList<>();
for (int i = 0; i < 156; i++) {
User user = new User();
user.setAuthority(Authority.CUSTOMER_USER);
user.setTenantId(tenantId);
user.setCustomerId(customerId);
user.setEmail("testCustomer" + i + "@thingsboard.org");
customerUsers.add(userService.saveUser(user));
}
List<User> loadedCustomerUsers = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(33);
do {
pageData = userService.findCustomerUsers(tenantId, customerId, pageLink);
loadedCustomerUsers.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(customerUsers, idComparator);
Collections.sort(loadedCustomerUsers, idComparator);
Assert.assertEquals(customerUsers, loadedCustomerUsers);
tenantService.deleteTenant(tenantId);
pageData = userService.findCustomerUsers(tenantId, customerId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
}
Aggregations