@ApiOperation(value = "Get Asset Profile names (getAssetProfileNames)",
            notes = "Returns a set of unique asset profile names owned by the tenant."
                    + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
    @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
    @RequestMapping(value = "/assetProfile/names", method = RequestMethod.GET)
    @ResponseBody
    public List<EntityInfo> getAssetProfileNames(
            @Parameter(description = "Flag indicating whether to retrieve exclusively the names of asset profiles that are referenced by tenant's assets.")
            @RequestParam(value = "activeOnly", required = false, defaultValue = "false") boolean activeOnly) throws ThingsboardException {
        SecurityUser user = getCurrentUser();
        TenantId tenantId = user.getTenantId();
        return checkNotNull(assetProfileService.findAssetProfileNamesByTenantId(tenantId, activeOnly));
    }
@Test
    public void testGetAssetProfileNames() throws Exception {
        var pageLink = new PageLink(Integer.MAX_VALUE);
        var assetProfileInfos = doGetTypedWithPageLink("/api/assetProfileInfos?",
                new TypeReference<PageData<AssetProfileInfo>>() {
                }, pageLink);
        Assert.assertNotNull("Asset Profile Infos page data is null!", assetProfileInfos);
        Assert.assertEquals("Asset Profile Infos Page data is empty! Expected to have default profile created!", 1, assetProfileInfos.getTotalElements());
        List<EntityInfo> expectedAssetProfileNames = assetProfileInfos.getData().stream()
                .map(info -> new EntityInfo(info.getId(), info.getName()))
                .sorted(Comparator.comparing(EntityInfo::getName))
                .collect(Collectors.toList());
        var assetProfileNames = doGetTyped("/api/assetProfile/names", new TypeReference<List<EntityInfo>>() {
        });
        Assert.assertNotNull("Asset Profile Names list is null!", assetProfileNames);
        Assert.assertFalse("Asset Profile Names list is empty!", assetProfileNames.isEmpty());
        Assert.assertEquals(expectedAssetProfileNames, assetProfileNames);
        Assert.assertEquals(1, assetProfileNames.size());
        Assert.assertEquals(DEFAULT_DEVICE_TYPE, assetProfileNames.get(0).getName());

        int count = 3;
        for (int i = 0; i < count; i++) {
            Asset asset = new Asset();
            asset.setName("AssetName" + i);
            asset.setType("AssetProfileName" + i);
            Asset savedAsset = doPost("/api/asset", asset, Asset.class);
            Assert.assertNotNull(savedAsset);
        }
        assetProfileInfos = doGetTypedWithPageLink("/api/assetProfileInfos?",
                new TypeReference<>() {
                }, pageLink);
        Assert.assertNotNull("Asset Profile Infos page data is null!", assetProfileInfos);
        Assert.assertEquals("Asset Profile Infos Page data is empty! Expected to have default profile created + count value!", 1 + count, assetProfileInfos.getTotalElements());
        expectedAssetProfileNames = assetProfileInfos.getData().stream()
                .map(info -> new EntityInfo(info.getId(), info.getName()))
                .sorted(Comparator.comparing(EntityInfo::getName))
                .collect(Collectors.toList());

        assetProfileNames = doGetTyped("/api/assetProfile/names", new TypeReference<>() {
        });
        Assert.assertNotNull("Asset Profile Names list is null!", assetProfileNames);
        Assert.assertFalse("Asset Profile Names list is empty!", assetProfileNames.isEmpty());
        Assert.assertEquals(expectedAssetProfileNames, assetProfileNames);
        Assert.assertEquals(1 + count, assetProfileNames.size());

        assetProfileNames = doGetTyped("/api/assetProfile/names?activeOnly=true", new TypeReference<>() {
        });
        Assert.assertNotNull("Asset Profile Names list is null!", assetProfileNames);
        Assert.assertFalse("Asset Profile Names list is empty!", assetProfileNames.isEmpty());
        var expectedAssetProfileNamesWithoutDefault = expectedAssetProfileNames.stream()
                .filter(entityInfo -> !entityInfo.getName().equals(DEFAULT_DEVICE_TYPE))
                .collect(Collectors.toList());
        Assert.assertEquals(expectedAssetProfileNamesWithoutDefault, assetProfileNames);
        Assert.assertEquals(count, assetProfileNames.size());
    }