@Test public void testFindAssetsByTenantIdAndName() { UUID assetId1 = Uuids.timeBased(); UUID assetId2 = Uuids.timeBased(); UUID tenantId1 = Uuids.timeBased(); UUID tenantId2 = Uuids.timeBased(); UUID customerId1 = Uuids.timeBased(); UUID customerId2 = Uuids.timeBased(); String name = "TEST_ASSET"; saveAsset(assetId1, tenantId1, customerId1, name, "TYPE_1"); saveAsset(assetId2, tenantId2, customerId2, name, "TYPE_1"); Optional<Asset> assetOpt1 = assetDao.findAssetsByTenantIdAndName(tenantId2, name); assertTrue("Optional expected to be non-empty", assetOpt1.isPresent()); assertEquals(assetId2, assetOpt1.get().getId().getId()); Optional<Asset> assetOpt2 = assetDao.findAssetsByTenantIdAndName(tenantId2, "NON_EXISTENT_NAME"); assertFalse("Optional expected to be empty", assetOpt2.isPresent()); }
@Override public Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name) { Asset asset = DaoUtil.getData(assetRepository.findByTenantIdAndName(tenantId, name)); return Optional.ofNullable(asset); }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name) { Asset asset = DaoUtil.getData(assetRepository.findByTenantIdAndName(tenantId, name)); return Optional.ofNullable(asset); } }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name) { Asset asset = DaoUtil.getData(assetRepository.findByTenantIdAndName(tenantId, name)); return Optional.ofNullable(asset); }  }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name) { Asset asset = DaoUtil.getData(assetRepository.findByTenantIdAndName(tenantId, name)); return Optional.ofNullable(asset); }  @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 Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name) { Asset asset = DaoUtil.getData(assetRepository.findByTenantIdAndName(tenantId, name)); return Optional.ofNullable(asset); }  @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);  }