JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId) { return service.submit(() -> convertTenantAssetTypesToDto(tenantId, assetRepository.findTenantAssetTypes(fromTimeUUID(tenantId)))); }  @Override List<Asset> findAssetsByTenantId(UUID tenantId, TextPageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds); @Override List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds); @Override Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name); @Override List<Asset> findAssetsByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink); @Override List<Asset> findAssetsByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, TextPageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId);  }
@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"))); }