### Question:
ResourceSetRegistrationEndpoint extends ServerResource { @Get public Representation readOrListResourceSet() throws NotFoundException, ServerException { String resourceSetId = getResourceSetId(); if (resourceSetId == null || resourceSetId.isEmpty()) { return listResourceSets(); } else { return readResourceSet(resourceSetId); } } @Inject  ResourceSetRegistrationEndpoint(OAuth2ProviderSettingsFactory providerSettingsFactory,
            ResourceSetDescriptionValidator validator, OAuth2RequestFactory<?, Request> requestFactory,
            Set<ResourceSetRegistrationHook> hooks, ResourceSetLabelRegistration labelRegistration,
            ExtensionFilterManager extensionFilterManager, ExceptionHandler exceptionHandler,
            UmaLabelsStore umaLabelsStore, JacksonRepresentationFactory jacksonRepresentationFactory); @Post Representation createResourceSet(JsonRepresentation entity); @Put Representation updateResourceSet(JsonRepresentation entity); @Get Representation readOrListResourceSet(); @Delete Representation deleteResourceSet();  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldReadResourceSetDescription() throws Exception { ResourceSetDescription resourceSetDescription = new ResourceSetDescription("RESOURCE_SET_ID", "CLIENT_ID", "RESOURCE_OWNER_ID", RESOURCE_SET_DESCRIPTION_CONTENT.asMap()); setUriResourceSetId(); given(store.read("RESOURCE_SET_ID", "RESOURCE_OWNER_ID")).willReturn(resourceSetDescription); Representation responseRep = endpoint.readOrListResourceSet(); Map<String, Object> responseBody = (Map<String, Object>) new ObjectMapper() .readValue(responseRep.getText(), Map.class); assertThat(responseBody).containsKey("_id"); assertThat(responseBody).contains(entry("name", "NAME"), entry("uri", "URI"), entry("type", "TYPE"), entry("scopes", Collections.singletonList("SCOPE")), entry("icon_uri", "ICON_URI")); }
@Test @SuppressWarnings("unchecked") public void shouldListResourceSetDescriptions() throws Exception { Set<ResourceSetDescription> resourceSetDescriptions = new HashSet<ResourceSetDescription>(); ResourceSetDescription resourceSetDescription = new ResourceSetDescription("RESOURCE_SET_ID", "CLIENT_ID", "RESOURCE_OWNER_ID", RESOURCE_SET_DESCRIPTION_CONTENT.asMap()); ResourceSetDescription resourceSetDescription2 = new ResourceSetDescription("RESOURCE_SET_ID_2", "CLIENT_ID", "RESOURCE_OWNER_ID", RESOURCE_SET_DESCRIPTION_UPDATED_CONTENT.asMap()); resourceSetDescriptions.add(resourceSetDescription); resourceSetDescriptions.add(resourceSetDescription2); noUriResourceSetId(); noConditions(); given(store.query(any(QueryFilter.class))) .willReturn(resourceSetDescriptions); Representation responseRep = endpoint.readOrListResourceSet(); ArgumentCaptor<QueryFilter> queryParametersCaptor = ArgumentCaptor.forClass(QueryFilter.class); verify(store).query(queryParametersCaptor.capture()); QueryFilter<String> query = queryParametersCaptor.getValue(); Map<String, String> params = query.accept(QUERY_PARAMS_EXTRACTOR, new HashMap<String, String>()); assertThat(params).contains( entry(ResourceSetTokenField.CLIENT_ID, "CLIENT_ID"), entry(ResourceSetTokenField.RESOURCE_OWNER_ID, "RESOURCE_OWNER_ID")); List<String> responseBody = (List<String>) new ObjectMapper() .readValue(responseRep.getText(), List.class); assertThat(responseBody).contains("RESOURCE_SET_ID", "RESOURCE_SET_ID_2"); }