use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaBaseRuleDaoTest method testFindAllTenantRulesByTenantId.
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindAllTenantRulesByTenantId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
createTenantsAndSystemRules(tenantId1, tenantId2, "name_", "token");
List<RuleMetaData> rules1 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_"));
assertEquals(40, rules1.size());
List<RuleMetaData> rules2 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_", rules1.get(19).getId().getId(), null));
assertEquals(20, rules2.size());
List<RuleMetaData> rules3 = ruleDao.findAllTenantRulesByTenantId(tenantId1, new TextPageLink(40, "name_", rules2.get(19).getId().getId(), null));
assertEquals(0, rules3.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaUserDaoTest method testFindTenantAdmins.
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindTenantAdmins() {
UUID tenantId = UUIDs.timeBased();
UUID customerId = UUIDs.timeBased();
create30Adminsand60Users(tenantId, customerId);
List<User> tenantAdmins1 = userDao.findTenantAdmins(tenantId, new TextPageLink(20));
assertEquals(20, tenantAdmins1.size());
List<User> tenantAdmins2 = userDao.findTenantAdmins(tenantId, new TextPageLink(20, null, tenantAdmins1.get(19).getId().getId(), null));
assertEquals(10, tenantAdmins2.size());
List<User> tenantAdmins3 = userDao.findTenantAdmins(tenantId, new TextPageLink(20, null, tenantAdmins2.get(9).getId().getId(), null));
assertEquals(0, tenantAdmins3.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaWidgetsBundleDaoTest method testFindWidgetsBundlesByTenantId.
@Test
@DatabaseSetup(value = "classpath:dbunit/widgets_bundle.xml", type = DatabaseOperation.DELETE_ALL)
public void testFindWidgetsBundlesByTenantId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
// Create a bunch of widgetBundles
for (int i = 0; i < 10; i++) {
createWidgetBundles(3, tenantId1, "WB1_");
createWidgetBundles(5, tenantId2, "WB2_");
createSystemWidgetBundles(10, "WB_SYS_");
}
assertEquals(180, widgetsBundleDao.find().size());
TextPageLink textPageLink1 = new TextPageLink(40, "WB");
List<WidgetsBundle> widgetsBundles1 = widgetsBundleDao.findTenantWidgetsBundlesByTenantId(tenantId1, textPageLink1);
assertEquals(30, widgetsBundles1.size());
TextPageLink textPageLink2 = new TextPageLink(40, "WB");
List<WidgetsBundle> widgetsBundles2 = widgetsBundleDao.findTenantWidgetsBundlesByTenantId(tenantId2, textPageLink2);
assertEquals(40, widgetsBundles2.size());
TextPageLink textPageLink3 = new TextPageLink(40, "WB", widgetsBundles2.get(39).getId().getId(), null);
List<WidgetsBundle> widgetsBundles3 = widgetsBundleDao.findTenantWidgetsBundlesByTenantId(tenantId2, textPageLink3);
assertEquals(10, widgetsBundles3.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaWidgetsBundleDaoTest method testFindSystemWidgetsBundles.
@Test
@DatabaseSetup(value = "classpath:dbunit/widgets_bundle.xml", type = DatabaseOperation.DELETE_ALL)
public void testFindSystemWidgetsBundles() {
createSystemWidgetBundles(30, "WB_");
assertEquals(30, widgetsBundleDao.find().size());
// Get first page
TextPageLink textPageLink1 = new TextPageLink(10, "WB");
List<WidgetsBundle> widgetsBundles1 = widgetsBundleDao.findSystemWidgetsBundles(textPageLink1);
assertEquals(10, widgetsBundles1.size());
// Get next page
TextPageLink textPageLink2 = new TextPageLink(10, "WB", widgetsBundles1.get(9).getId().getId(), null);
List<WidgetsBundle> widgetsBundles2 = widgetsBundleDao.findSystemWidgetsBundles(textPageLink2);
assertEquals(10, widgetsBundles2.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class BasePluginServiceTest method findTenantPlugins.
@Test
public void findTenantPlugins() throws Exception {
TenantId tenantId = new TenantId(UUIDs.timeBased());
pluginService.savePlugin(generatePlugin(null, null));
pluginService.savePlugin(generatePlugin(null, null));
pluginService.savePlugin(generatePlugin(tenantId, null));
pluginService.savePlugin(generatePlugin(tenantId, null));
pluginService.savePlugin(generatePlugin(tenantId, null));
TextPageData<PluginMetaData> found = pluginService.findTenantPlugins(tenantId, new TextPageLink(100));
Assert.assertEquals(3, found.getData().size());
}
Aggregations