use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaAssetDaoTest method testFindAssetsByTenantIdAndCustomerId.
@Test
public void testFindAssetsByTenantIdAndCustomerId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
UUID customerId1 = UUIDs.timeBased();
UUID customerId2 = UUIDs.timeBased();
for (int i = 0; i < 60; i++) {
UUID assetId = UUIDs.timeBased();
UUID tenantId = i % 2 == 0 ? tenantId1 : tenantId2;
UUID customerId = i % 2 == 0 ? customerId1 : customerId2;
saveAsset(assetId, tenantId, customerId, "ASSET_" + i, "TYPE_1");
}
TextPageLink pageLink1 = new TextPageLink(20, "ASSET_");
List<Asset> assets1 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink1);
assertEquals(20, assets1.size());
TextPageLink pageLink2 = new TextPageLink(20, "ASSET_", assets1.get(19).getId().getId(), null);
List<Asset> assets2 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink2);
assertEquals(10, assets2.size());
TextPageLink pageLink3 = new TextPageLink(20, "ASSET_", assets2.get(9).getId().getId(), null);
List<Asset> assets3 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink3);
assertEquals(0, assets3.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaUserDaoTest method testFindCustomerUsers.
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindCustomerUsers() {
UUID tenantId = UUIDs.timeBased();
UUID customerId = UUIDs.timeBased();
create30Adminsand60Users(tenantId, customerId);
List<User> customerUsers1 = userDao.findCustomerUsers(tenantId, customerId, new TextPageLink(40));
assertEquals(40, customerUsers1.size());
List<User> customerUsers2 = userDao.findCustomerUsers(tenantId, customerId, new TextPageLink(20, null, customerUsers1.get(39).getId().getId(), null));
assertEquals(20, customerUsers2.size());
List<User> customerUsers3 = userDao.findCustomerUsers(tenantId, customerId, new TextPageLink(20, null, customerUsers2.get(19).getId().getId(), null));
assertEquals(0, customerUsers3.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaWidgetsBundleDaoTest method testSearchTextNotFound.
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
@DatabaseTearDown(value = "classpath:dbunit/empty_dataset.xml", type = DatabaseOperation.DELETE_ALL)
public void testSearchTextNotFound() {
UUID tenantId = UUIDs.timeBased();
createWidgetBundles(5, tenantId, "ABC_");
createSystemWidgetBundles(5, "SYS_");
TextPageLink textPageLink = new TextPageLink(30, "TEXT_NOT_FOUND");
List<WidgetsBundle> widgetsBundles4 = widgetsBundleDao.findAllTenantWidgetsBundlesByTenantId(tenantId, textPageLink);
assertEquals(0, widgetsBundles4.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaWidgetsBundleDaoTest method testFindAllWidgetsBundlesByTenantId.
@Test
@DatabaseSetup(value = "classpath:dbunit/widgets_bundle.xml", type = DatabaseOperation.DELETE_ALL)
public void testFindAllWidgetsBundlesByTenantId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
// Create a bunch of widgetBundles
for (int i = 0; i < 10; i++) {
createWidgetBundles(5, tenantId1, "WB1_");
createWidgetBundles(3, tenantId2, "WB2_");
createSystemWidgetBundles(2, "WB_SYS_");
}
TextPageLink textPageLink1 = new TextPageLink(30, "WB");
List<WidgetsBundle> widgetsBundles1 = widgetsBundleDao.findAllTenantWidgetsBundlesByTenantId(tenantId1, textPageLink1);
assertEquals(30, widgetsBundles1.size());
TextPageLink textPageLink2 = new TextPageLink(30, "WB", widgetsBundles1.get(29).getId().getId(), null);
List<WidgetsBundle> widgetsBundles2 = widgetsBundleDao.findAllTenantWidgetsBundlesByTenantId(tenantId1, textPageLink2);
assertEquals(30, widgetsBundles2.size());
TextPageLink textPageLink3 = new TextPageLink(30, "WB", widgetsBundles2.get(29).getId().getId(), null);
List<WidgetsBundle> widgetsBundles3 = widgetsBundleDao.findAllTenantWidgetsBundlesByTenantId(tenantId1, textPageLink3);
assertEquals(10, widgetsBundles3.size());
TextPageLink textPageLink4 = new TextPageLink(30, "WB", widgetsBundles3.get(9).getId().getId(), null);
List<WidgetsBundle> widgetsBundles4 = widgetsBundleDao.findAllTenantWidgetsBundlesByTenantId(tenantId1, textPageLink4);
assertEquals(0, widgetsBundles4.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class BasePluginServiceTest method findSystemPlugins.
@Test
public void findSystemPlugins() throws Exception {
// system tenant id
TenantId systemTenant = new TenantId(ModelConstants.NULL_UUID);
pluginService.savePlugin(generatePlugin(null, null));
pluginService.savePlugin(generatePlugin(null, null));
pluginService.savePlugin(generatePlugin(systemTenant, null));
pluginService.savePlugin(generatePlugin(systemTenant, null));
TextPageData<PluginMetaData> found = pluginService.findSystemPlugins(new TextPageLink(100));
Assert.assertEquals(2, found.getData().size());
Assert.assertFalse(found.hasNext());
}
Aggregations