use of org.thingsboard.server.common.data.widget.WidgetsBundle 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.widget.WidgetsBundle in project thingsboard by thingsboard.
the class JpaWidgetsBundleDaoTest method createSystemWidgetBundles.
private void createSystemWidgetBundles(int count, String prefix) {
for (int i = 0; i < count; i++) {
WidgetsBundle widgetsBundle = new WidgetsBundle();
widgetsBundle.setAlias(prefix + i);
widgetsBundle.setTitle(prefix + i);
widgetsBundle.setTenantId(new TenantId(NULL_UUID));
widgetsBundle.setId(new WidgetsBundleId(UUIDs.timeBased()));
widgetsBundleDao.save(widgetsBundle);
}
}
use of org.thingsboard.server.common.data.widget.WidgetsBundle 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.widget.WidgetsBundle in project thingsboard by thingsboard.
the class JpaWidgetsBundleDaoTest method createWidgetBundles.
private void createWidgetBundles(int count, UUID tenantId, String prefix) {
for (int i = 0; i < count; i++) {
WidgetsBundle widgetsBundle = new WidgetsBundle();
widgetsBundle.setAlias(prefix + i);
widgetsBundle.setTitle(prefix + i);
widgetsBundle.setId(new WidgetsBundleId(UUIDs.timeBased()));
widgetsBundle.setTenantId(new TenantId(tenantId));
widgetsBundleDao.save(widgetsBundle);
}
}
use of org.thingsboard.server.common.data.widget.WidgetsBundle in project thingsboard by thingsboard.
the class BaseController method checkWidgetsBundleId.
WidgetsBundle checkWidgetsBundleId(WidgetsBundleId widgetsBundleId, boolean modify) throws ThingsboardException {
try {
validateId(widgetsBundleId, "Incorrect widgetsBundleId " + widgetsBundleId);
WidgetsBundle widgetsBundle = widgetsBundleService.findWidgetsBundleById(widgetsBundleId);
checkWidgetsBundle(widgetsBundle, modify);
return widgetsBundle;
} catch (Exception e) {
throw handleException(e, false);
}
}
Aggregations