@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"); } PageLink pageLink = new PageLink(20, 0, "ASSET_"); PageData<Asset> assets1 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink); assertEquals(20, assets1.getData().size()); pageLink = pageLink.nextPageLink(); PageData<Asset> assets2 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink); assertEquals(10, assets2.getData().size()); pageLink = pageLink.nextPageLink(); PageData<Asset> assets3 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink); assertEquals(0, assets3.getData().size()); }
@Override public PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink) { return DaoUtil.toPageData(assetRepository .findByTenantIdAndCustomerId( tenantId, customerId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink) { return DaoUtil.toPageData(assetRepository .findByTenantIdAndCustomerId( tenantId, customerId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); } }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink) { return DaoUtil.toPageData(assetRepository .findByTenantIdAndCustomerId( tenantId, customerId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); }  }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink) { return DaoUtil.toPageData(assetRepository .findByTenantIdAndCustomerId( tenantId, customerId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); }  @Override AssetInfo findAssetInfoById(TenantId tenantId, UUID assetId); @Override PageData<Asset> findAssetsByTenantId(UUID tenantId, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantId(UUID tenantId, PageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds); @Override PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds); @Override Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name); @Override PageData<Asset> findAssetsByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<Asset> findAssetsByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId); }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink) { return DaoUtil.toPageData(assetRepository .findByTenantIdAndCustomerId( tenantId, customerId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); }  @Override AssetInfo findAssetInfoById(TenantId tenantId, UUID assetId); @Override PageData<Asset> findAssetsByTenantId(UUID tenantId, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantId(UUID tenantId, PageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds); @Override PageData<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds); @Override Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name); @Override PageData<Asset> findAssetsByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<Asset> findAssetsByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<AssetInfo> findAssetInfosByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId);  }