@Test public void testFindTenantAssetTypesAsync() throws ExecutionException, InterruptedException { UUID assetId1 = Uuids.timeBased(); UUID assetId2 = Uuids.timeBased(); UUID tenantId1 = Uuids.timeBased(); UUID tenantId2 = Uuids.timeBased(); UUID customerId1 = Uuids.timeBased(); UUID customerId2 = Uuids.timeBased(); saveAsset(Uuids.timeBased(), tenantId1, customerId1, "TEST_ASSET_1", "TYPE_1"); saveAsset(Uuids.timeBased(), tenantId1, customerId1, "TEST_ASSET_2", "TYPE_1"); saveAsset(Uuids.timeBased(), tenantId1, customerId1, "TEST_ASSET_3", "TYPE_2"); saveAsset(Uuids.timeBased(), tenantId1, customerId1, "TEST_ASSET_4", "TYPE_3"); saveAsset(Uuids.timeBased(), tenantId1, customerId1, "TEST_ASSET_5", "TYPE_3"); saveAsset(Uuids.timeBased(), tenantId1, customerId1, "TEST_ASSET_6", "TYPE_3"); saveAsset(Uuids.timeBased(), tenantId2, customerId2, "TEST_ASSET_7", "TYPE_4"); saveAsset(Uuids.timeBased(), tenantId2, customerId2, "TEST_ASSET_8", "TYPE_1"); saveAsset(Uuids.timeBased(), tenantId2, customerId2, "TEST_ASSET_9", "TYPE_1"); List<EntitySubtype> tenant1Types = assetDao.findTenantAssetTypesAsync(tenantId1).get(); assertNotNull(tenant1Types); List<EntitySubtype> tenant2Types = assetDao.findTenantAssetTypesAsync(tenantId2).get(); assertNotNull(tenant2Types); assertEquals(3, tenant1Types.size()); assertTrue(tenant1Types.stream().anyMatch(t -> t.getType().equals("TYPE_1"))); assertTrue(tenant1Types.stream().anyMatch(t -> t.getType().equals("TYPE_2"))); assertTrue(tenant1Types.stream().anyMatch(t -> t.getType().equals("TYPE_3"))); assertFalse(tenant1Types.stream().anyMatch(t -> t.getType().equals("TYPE_4"))); assertEquals(2, tenant2Types.size()); assertTrue(tenant2Types.stream().anyMatch(t -> t.getType().equals("TYPE_1"))); assertTrue(tenant2Types.stream().anyMatch(t -> t.getType().equals("TYPE_4"))); assertFalse(tenant2Types.stream().anyMatch(t -> t.getType().equals("TYPE_2"))); assertFalse(tenant2Types.stream().anyMatch(t -> t.getType().equals("TYPE_3"))); }
@Override public ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId) { return service.submit(() -> convertTenantAssetTypesToDto(tenantId, assetRepository.findTenantAssetTypes(tenantId))); }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId) { return service.submit(() -> convertTenantAssetTypesToDto(tenantId, assetRepository.findTenantAssetTypes(tenantId))); } }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId) { return service.submit(() -> convertTenantAssetTypesToDto(tenantId, assetRepository.findTenantAssetTypes(tenantId))); }  }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId) { return service.submit(() -> convertTenantAssetTypesToDto(tenantId, assetRepository.findTenantAssetTypes(tenantId))); }  @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 ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId) { return service.submit(() -> convertTenantAssetTypesToDto(tenantId, assetRepository.findTenantAssetTypes(tenantId))); }  @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);  }