@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
    @GetMapping("/api/images")
    public PageData<TbResourceInfo> getImages(@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
                                              @RequestParam int pageSize,
                                              @Parameter(description = PAGE_NUMBER_DESCRIPTION, required = true)
                                              @RequestParam int page,
                                              @Parameter(description = RESOURCE_IMAGE_SUB_TYPE_DESCRIPTION, schema = @Schema(allowableValues = {"IMAGE", "SCADA_SYMBOL"}))
                                              @RequestParam(required = false) String imageSubType,
                                              @Parameter(description = RESOURCE_INCLUDE_SYSTEM_IMAGES_DESCRIPTION)
                                              @RequestParam(required = false) boolean includeSystemImages,
                                              @Parameter(description = RESOURCE_TEXT_SEARCH_DESCRIPTION)
                                              @RequestParam(required = false) String textSearch,
                                              @Parameter(description = SORT_PROPERTY_DESCRIPTION, schema = @Schema(allowableValues = {"createdTime", "title", "resourceType", "tenantId"}))
                                              @RequestParam(required = false) String sortProperty,
                                              @Parameter(description = SORT_ORDER_DESCRIPTION, schema = @Schema(allowableValues = {"ASC", "DESC"}))
                                              @RequestParam(required = false) String sortOrder) throws ThingsboardException {
        // PE: generic permission
        PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
        TenantId tenantId = getTenantId();
        ResourceSubType subType = ResourceSubType.IMAGE;
        if (StringUtils.isNotEmpty(imageSubType)) {
            subType = ResourceSubType.valueOf(imageSubType);
        }
        if (getCurrentUser().getAuthority() == Authority.SYS_ADMIN || !includeSystemImages) {
            return checkNotNull(imageService.getImagesByTenantId(tenantId, subType, pageLink));
        } else {
            return checkNotNull(imageService.getAllImagesByTenantId(tenantId, subType, pageLink));
        }
    }
@Test
    public void testGetImages() throws Exception {
        loginSysAdmin();
        String systemImageName = "my_system_png_image.png";
        TbResourceInfo systemImage = uploadImage(HttpMethod.POST, "/api/image", systemImageName, "image/png", PNG_IMAGE);

        String systemScadaSymbolName  = "my_system_scada_symbol_image.svg";
        TbResourceInfo systemScadaSymbol = uploadImage(HttpMethod.POST, "/api/image", ResourceSubType.SCADA_SYMBOL.name(), systemScadaSymbolName, "image/svg+xml", SVG_IMAGE);

        loginTenantAdmin();
        String tenantImageName = "my_jpeg_image.jpg";
        TbResourceInfo tenantImage = uploadImage(HttpMethod.POST, "/api/image", tenantImageName, "image/jpeg", JPEG_IMAGE);

        String tenantScadaSymbolName  = "my_scada_symbol_image.svg";
        TbResourceInfo tenantScadaSymbol = uploadImage(HttpMethod.POST, "/api/image", ResourceSubType.SCADA_SYMBOL.name(), tenantScadaSymbolName, "image/svg+xml", SVG_IMAGE);

        List<TbResourceInfo> tenantImages = getImages(null, false, 10);
        assertThat(tenantImages).containsOnly(tenantImage);

        List<TbResourceInfo> tenantScadaSymbols = getImages(null, ResourceSubType.SCADA_SYMBOL.name(), false, 10);
        assertThat(tenantScadaSymbols).containsOnly(tenantScadaSymbol);

        List<TbResourceInfo> allImages = getImages(null, true, 10);
        assertThat(allImages).containsOnly(tenantImage, systemImage);

        List<TbResourceInfo> allScadaSymbols = getImages(null, ResourceSubType.SCADA_SYMBOL.name(), true, 10);
        assertThat(allScadaSymbols).containsOnly(tenantScadaSymbol, systemScadaSymbol);

        assertThat(getImages("png", true, 10))
                .containsOnly(systemImage);
        assertThat(getImages("jpg", true, 10))
                .containsOnly(tenantImage);

        assertThat(getImages("my_system_scada_symbol", ResourceSubType.SCADA_SYMBOL.name(), true, 10))
                .containsOnly(systemScadaSymbol);
        assertThat(getImages("my_scada_symbol", ResourceSubType.SCADA_SYMBOL.name(),true, 10))
                .containsOnly(tenantScadaSymbol);
    }