use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class BasePluginService method findSystemPlugins.
@Override
public List<PluginMetaData> findSystemPlugins() {
log.trace("Executing findSystemPlugins");
List<PluginMetaData> plugins = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(300);
TextPageData<PluginMetaData> pageData = null;
do {
pageData = findSystemPlugins(pageLink);
plugins.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
return plugins;
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class BasePluginService method findAllTenantPluginsByTenantId.
@Override
public List<PluginMetaData> findAllTenantPluginsByTenantId(TenantId tenantId) {
log.trace("Executing findAllTenantPluginsByTenantId, tenantId [{}]", tenantId);
Validator.validateId(tenantId, "Incorrect tenantId " + tenantId);
List<PluginMetaData> plugins = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(300);
TextPageData<PluginMetaData> pageData = null;
do {
pageData = findAllTenantPluginsByTenantIdAndPageLink(tenantId, pageLink);
plugins.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
return plugins;
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class BaseCustomerServiceTest method testFindCustomersByTenantIdAndTitle.
@Test
public void testFindCustomersByTenantIdAndTitle() {
String title1 = "Customer title 1";
List<Customer> customersTitle1 = new ArrayList<>();
for (int i = 0; i < 143; i++) {
Customer customer = new Customer();
customer.setTenantId(tenantId);
String suffix = RandomStringUtils.randomAlphanumeric((int) (5 + Math.random() * 10));
String title = title1 + suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
customer.setTitle(title);
customersTitle1.add(customerService.saveCustomer(customer));
}
String title2 = "Customer title 2";
List<Customer> customersTitle2 = new ArrayList<>();
for (int i = 0; i < 175; i++) {
Customer customer = new Customer();
customer.setTenantId(tenantId);
String suffix = RandomStringUtils.randomAlphanumeric((int) (5 + Math.random() * 10));
String title = title2 + suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
customer.setTitle(title);
customersTitle2.add(customerService.saveCustomer(customer));
}
List<Customer> loadedCustomersTitle1 = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(15, title1);
TextPageData<Customer> pageData = null;
do {
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
loadedCustomersTitle1.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(customersTitle1, idComparator);
Collections.sort(loadedCustomersTitle1, idComparator);
Assert.assertEquals(customersTitle1, loadedCustomersTitle1);
List<Customer> loadedCustomersTitle2 = new ArrayList<>();
pageLink = new TextPageLink(4, title2);
do {
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
loadedCustomersTitle2.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(customersTitle2, idComparator);
Collections.sort(loadedCustomersTitle2, idComparator);
Assert.assertEquals(customersTitle2, loadedCustomersTitle2);
for (Customer customer : loadedCustomersTitle1) {
customerService.deleteCustomer(customer.getId());
}
pageLink = new TextPageLink(4, title1);
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(0, pageData.getData().size());
for (Customer customer : loadedCustomersTitle2) {
customerService.deleteCustomer(customer.getId());
}
pageLink = new TextPageLink(4, title2);
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(0, pageData.getData().size());
}
use of org.thingsboard.server.common.data.page.TextPageLink 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.page.TextPageLink in project thingsboard by thingsboard.
the class BaseDashboardServiceTest method testFindDashboardsByTenantIdAndTitle.
@Test
public void testFindDashboardsByTenantIdAndTitle() {
String title1 = "Dashboard title 1";
List<DashboardInfo> dashboardsTitle1 = new ArrayList<>();
for (int i = 0; i < 123; i++) {
Dashboard dashboard = new Dashboard();
dashboard.setTenantId(tenantId);
String suffix = RandomStringUtils.randomAlphanumeric((int) (Math.random() * 17));
String title = title1 + suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
dashboard.setTitle(title);
dashboardsTitle1.add(new DashboardInfo(dashboardService.saveDashboard(dashboard)));
}
String title2 = "Dashboard title 2";
List<DashboardInfo> dashboardsTitle2 = new ArrayList<>();
for (int i = 0; i < 193; i++) {
Dashboard dashboard = new Dashboard();
dashboard.setTenantId(tenantId);
String suffix = RandomStringUtils.randomAlphanumeric((int) (Math.random() * 15));
String title = title2 + suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
dashboard.setTitle(title);
dashboardsTitle2.add(new DashboardInfo(dashboardService.saveDashboard(dashboard)));
}
List<DashboardInfo> loadedDashboardsTitle1 = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(19, title1);
TextPageData<DashboardInfo> pageData = null;
do {
pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink);
loadedDashboardsTitle1.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(dashboardsTitle1, idComparator);
Collections.sort(loadedDashboardsTitle1, idComparator);
Assert.assertEquals(dashboardsTitle1, loadedDashboardsTitle1);
List<DashboardInfo> loadedDashboardsTitle2 = new ArrayList<>();
pageLink = new TextPageLink(4, title2);
do {
pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink);
loadedDashboardsTitle2.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(dashboardsTitle2, idComparator);
Collections.sort(loadedDashboardsTitle2, idComparator);
Assert.assertEquals(dashboardsTitle2, loadedDashboardsTitle2);
for (DashboardInfo dashboard : loadedDashboardsTitle1) {
dashboardService.deleteDashboard(dashboard.getId());
}
pageLink = new TextPageLink(4, title1);
pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(0, pageData.getData().size());
for (DashboardInfo dashboard : loadedDashboardsTitle2) {
dashboardService.deleteDashboard(dashboard.getId());
}
pageLink = new TextPageLink(4, title2);
pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(0, pageData.getData().size());
}
Aggregations