ChannelTypeResource implements RESTResource { @GET @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Gets all available channel types.", responses = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ChannelTypeDTO.class), uniqueItems = true))) }) public Response getAll( @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language, @QueryParam("prefixes") @Parameter(description = "filter UIDs by prefix (multiple comma-separated prefixes allowed, for example: 'system,mqtt')") @Nullable String prefixes) { Locale locale = localeService.getLocale(language); Stream<ChannelTypeDTO> channelStream = channelTypeRegistry.getChannelTypes(locale).stream() .map(c -> convertToChannelTypeDTO(c, locale)); if (prefixes != null) { Predicate<ChannelTypeDTO> filter = ct -> false; for (String prefix : prefixes.split(",")) { filter = filter.or(ct -> ct.UID.startsWith(prefix + ":")); } channelStream = channelStream.filter(filter); } return Response.ok(new Stream2JSONInputStream(channelStream)).build(); } @Activate  ChannelTypeResource( //
            final @Reference ChannelTypeRegistry channelTypeRegistry,
            final @Reference ConfigDescriptionRegistry configDescriptionRegistry,
            final @Reference LocaleService localeService, //
            final @Reference ProfileTypeRegistry profileTypeRegistry); @GET @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Gets all available channel types.", responses = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ChannelTypeDTO.class), uniqueItems = true))) }) Response getAll(
            @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language,
            @QueryParam("prefixes") @Parameter(description = "filter UIDs by prefix (multiple comma-separated prefixes allowed, for example: 'system,mqtt')") @Nullable String prefixes); @GET @Path("/{channelTypeUID}") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Gets channel type by UID.", responses = { @ApiResponse(responseCode = "200", description = "Channel type with provided channelTypeUID does not exist.", content = @Content(schema = @Schema(implementation = ChannelTypeDTO.class))), @ApiResponse(responseCode = "404", description = "No content") }) Response getByUID(
            @PathParam("channelTypeUID") @Parameter(description = "channelTypeUID") String channelTypeUID,
            @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language); @GET @Path("/{channelTypeUID}/linkableItemTypes") @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Gets the item types the given trigger channel type UID can be linked to.", responses = { @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class), uniqueItems = true))), @ApiResponse(responseCode = "204", description = "No content: channel type has no linkable items or is no trigger channel."), @ApiResponse(responseCode = "404", description = "Given channel type UID not found.") }) Response getLinkableItemTypes(
            @PathParam("channelTypeUID") @Parameter(description = "channelTypeUID") String channelTypeUID); static final String PATH_CHANNEL_TYPES; }
@Test public void getAllShouldRetrieveAllChannelTypes() throws Exception { when(localeService.getLocale(null)).thenReturn(Locale.ENGLISH); channelTypeResource.getAll(null, null); verify(channelTypeRegistry).getChannelTypes(Locale.ENGLISH); }