use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class BaseWidgetsBundleControllerTest method testFindSystemWidgetsBundlesByPageLink.
@Test
public void testFindSystemWidgetsBundlesByPageLink() throws Exception {
loginSysAdmin();
List<WidgetsBundle> sysWidgetsBundles = doGetTyped("/api/widgetsBundles?", new TypeReference<List<WidgetsBundle>>() {
});
List<WidgetsBundle> createdWidgetsBundles = new ArrayList<>();
for (int i = 0; i < 120; i++) {
WidgetsBundle widgetsBundle = new WidgetsBundle();
widgetsBundle.setTitle("Widgets bundle" + i);
createdWidgetsBundles.add(doPost("/api/widgetsBundle", widgetsBundle, WidgetsBundle.class));
}
List<WidgetsBundle> widgetsBundles = new ArrayList<>(createdWidgetsBundles);
widgetsBundles.addAll(sysWidgetsBundles);
List<WidgetsBundle> loadedWidgetsBundles = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(14);
TextPageData<WidgetsBundle> pageData;
do {
pageData = doGetTypedWithPageLink("/api/widgetsBundles?", new TypeReference<TextPageData<WidgetsBundle>>() {
}, pageLink);
loadedWidgetsBundles.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(widgetsBundles, idComparator);
Collections.sort(loadedWidgetsBundles, idComparator);
Assert.assertEquals(widgetsBundles, loadedWidgetsBundles);
for (WidgetsBundle widgetsBundle : createdWidgetsBundles) {
doDelete("/api/widgetsBundle/" + widgetsBundle.getId().getId().toString()).andExpect(status().isOk());
}
pageLink = new TextPageLink(17);
loadedWidgetsBundles.clear();
do {
pageData = doGetTypedWithPageLink("/api/widgetsBundles?", new TypeReference<TextPageData<WidgetsBundle>>() {
}, pageLink);
loadedWidgetsBundles.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
Collections.sort(sysWidgetsBundles, idComparator);
Collections.sort(loadedWidgetsBundles, idComparator);
Assert.assertEquals(sysWidgetsBundles, loadedWidgetsBundles);
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaBaseComponentDescriptorDaoTest method findByTypeAndSocpe.
@Test
public void findByTypeAndSocpe() {
for (int i = 0; i < 20; i++) {
createComponentDescriptor(ComponentType.PLUGIN, ComponentScope.SYSTEM, i);
createComponentDescriptor(ComponentType.ACTION, ComponentScope.TENANT, i + 20);
createComponentDescriptor(ComponentType.FILTER, ComponentScope.SYSTEM, i + 40);
}
TextPageLink pageLink1 = new TextPageLink(15, "COMPONENT_");
List<ComponentDescriptor> components1 = componentDescriptorDao.findByScopeAndTypeAndPageLink(ComponentScope.SYSTEM, ComponentType.FILTER, pageLink1);
assertEquals(15, components1.size());
TextPageLink pageLink2 = new TextPageLink(15, "COMPONENT_", components1.get(14).getId().getId(), null);
List<ComponentDescriptor> components2 = componentDescriptorDao.findByScopeAndTypeAndPageLink(ComponentScope.SYSTEM, ComponentType.FILTER, pageLink2);
assertEquals(5, components2.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaBaseComponentDescriptorDaoTest method findByType.
@Test
public void findByType() {
for (int i = 0; i < 20; i++) {
createComponentDescriptor(ComponentType.PLUGIN, ComponentScope.SYSTEM, i);
createComponentDescriptor(ComponentType.ACTION, ComponentScope.TENANT, i + 20);
}
TextPageLink pageLink1 = new TextPageLink(15, "COMPONENT_");
List<ComponentDescriptor> components1 = componentDescriptorDao.findByTypeAndPageLink(ComponentType.PLUGIN, pageLink1);
assertEquals(15, components1.size());
TextPageLink pageLink2 = new TextPageLink(15, "COMPONENT_", components1.get(14).getId().getId(), null);
List<ComponentDescriptor> components2 = componentDescriptorDao.findByTypeAndPageLink(ComponentType.PLUGIN, pageLink2);
assertEquals(5, components2.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaCustomerDaoTest method testFindByTenantId.
@Test
public void testFindByTenantId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
for (int i = 0; i < 20; i++) {
createCustomer(tenantId1, i);
createCustomer(tenantId2, i * 2);
}
TextPageLink pageLink1 = new TextPageLink(15, "CUSTOMER");
List<Customer> customers1 = customerDao.findCustomersByTenantId(tenantId1, pageLink1);
assertEquals(15, customers1.size());
TextPageLink pageLink2 = new TextPageLink(15, "CUSTOMER", customers1.get(14).getId().getId(), null);
List<Customer> customers2 = customerDao.findCustomersByTenantId(tenantId1, pageLink2);
assertEquals(5, customers2.size());
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class JpaDashboardInfoDaoTest method testFindDashboardsByTenantId.
@Test
public void testFindDashboardsByTenantId() {
UUID tenantId1 = UUIDs.timeBased();
UUID tenantId2 = UUIDs.timeBased();
for (int i = 0; i < 20; i++) {
createDashboard(tenantId1, i);
createDashboard(tenantId2, i * 2);
}
TextPageLink pageLink1 = new TextPageLink(15, "DASHBOARD");
List<DashboardInfo> dashboardInfos1 = dashboardInfoDao.findDashboardsByTenantId(tenantId1, pageLink1);
Assert.assertEquals(15, dashboardInfos1.size());
TextPageLink pageLink2 = new TextPageLink(15, "DASHBOARD", dashboardInfos1.get(14).getId().getId(), null);
List<DashboardInfo> dashboardInfos2 = dashboardInfoDao.findDashboardsByTenantId(tenantId1, pageLink2);
Assert.assertEquals(5, dashboardInfos2.size());
}
Aggregations