JpaWidgetsBundleDao extends JpaAbstractSearchTextDao<WidgetsBundleEntity, WidgetsBundle> implements WidgetsBundleDao { @Override public List<WidgetsBundle> findAllTenantWidgetsBundlesByTenantId(UUID tenantId, TextPageLink pageLink) { return DaoUtil.convertDataList( widgetsBundleRepository .findAllTenantWidgetsBundlesByTenantId( UUIDConverter.fromTimeUUID(tenantId), NULL_UUID_STR, Objects.toString(pageLink.getTextSearch(), ""), pageLink.getIdOffset() == null ? NULL_UUID_STR : UUIDConverter.fromTimeUUID(pageLink.getIdOffset()), new PageRequest(0, pageLink.getLimit()))); }  @Override WidgetsBundle findWidgetsBundleByTenantIdAndAlias(UUID tenantId, String alias); @Override List<WidgetsBundle> findSystemWidgetsBundles(TextPageLink pageLink); @Override List<WidgetsBundle> findTenantWidgetsBundlesByTenantId(UUID tenantId, TextPageLink pageLink); @Override List<WidgetsBundle> findAllTenantWidgetsBundlesByTenantId(UUID tenantId, TextPageLink pageLink);  }
@Test @DatabaseSetup(value = "classpath:dbunit/widgets_bundle.xml", type= DatabaseOperation.DELETE_ALL) public void testFindAllWidgetsBundlesByTenantId() { UUID tenantId1 = UUIDs.timeBased(); UUID tenantId2 = UUIDs.timeBased(); 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()); }
@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()); }