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

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

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

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