ChannelTypeResource implements RESTResource { @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.") }) public Response getLinkableItemTypes( @PathParam("channelTypeUID") @Parameter(description = "channelTypeUID") String channelTypeUID) { ChannelTypeUID ctUID = new ChannelTypeUID(channelTypeUID); ChannelType channelType = channelTypeRegistry.getChannelType(ctUID); if (channelType == null) { return Response.status(Status.NOT_FOUND).build(); } if (channelType.getKind() != ChannelKind.TRIGGER) { return Response.noContent().build(); } Set<String> result = new HashSet<>(); for (ProfileType profileType : profileTypeRegistry.getProfileTypes()) { if (profileType instanceof TriggerProfileType) { if (((TriggerProfileType) profileType).getSupportedChannelTypeUIDs().contains(ctUID)) { for (String itemType : profileType.getSupportedItemTypes()) { result.add(itemType); } } } } if (result.isEmpty()) { return Response.noContent().build(); } return Response.ok(result).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; }
@SuppressWarnings("unchecked") @Test public void returnLinkableItemTypesForTriggerChannelType() throws IOException { ChannelTypeUID channelTypeUID = new ChannelTypeUID("binding", "ct"); ChannelType channelType = ChannelTypeBuilder.trigger(channelTypeUID, "Label").build(); when(channelTypeRegistry.getChannelType(channelTypeUID)).thenReturn(channelType); TriggerProfileType profileType = mock(TriggerProfileType.class); when(profileType.getSupportedChannelTypeUIDs()).thenReturn(List.of(channelTypeUID)); when(profileType.getSupportedItemTypes()).thenReturn(List.of("Switch", "Dimmer")); when(profileTypeRegistry.getProfileTypes()).thenReturn(List.of(profileType)); Response response = channelTypeResource.getLinkableItemTypes(channelTypeUID.getAsString()); verify(channelTypeRegistry).getChannelType(channelTypeUID); verify(profileTypeRegistry).getProfileTypes(); assertThat(response.getStatus(), is(200)); assertThat((Set<String>) response.getEntity(), IsIterableContaining.hasItems("Switch", "Dimmer")); }