@Test public void resolveTermsIgnoresUnprefixedTerms() { when(this.request.getProperties(TERM_ID)).thenReturn(Arrays.asList(TERM_1_ID, INVALID, TERM_2_ID, TERM_3_ID)); final Response response = this.component.resolveTerms(); final JSONObject expected = new JSONObject() .put(LINKS_FIELD, new JSONArray()) .put(ROWS_FIELD, new JSONArray() .put(new JSONObject() .put(LINKS_FIELD, new JSONArray()) .put(ID_FIELD, TERM_1_ID)) .put(new JSONObject() .put(LINKS_FIELD, new JSONArray()) .put(ID_FIELD, TERM_2_ID)) .put(new JSONObject() .put(LINKS_FIELD, new JSONArray()) .put(ID_FIELD, TERM_3_ID))); final JSONObject actual = (JSONObject) response.getEntity(); Assert.assertEquals(expected.length(), actual.length()); Assert.assertTrue(expected.getJSONArray(LINKS_FIELD).similar(actual.getJSONArray(LINKS_FIELD))); Assert.assertEquals(new HashSet<>(expected.getJSONArray(ROWS_FIELD).toList()), new HashSet<>(actual.getJSONArray(ROWS_FIELD).toList())); verify(this.logger, times(1)).warn("Term [{}] does not begin with a valid prefix", INVALID); }
@Override public Response resolveTerms() { final Request request = this.container.getRequest(); final List<Object> termIds = request.getProperties(TERM_ID); if (CollectionUtils.isEmpty(termIds)) { this.slf4Jlogger.info("No content provided."); return Response.status(Response.Status.NO_CONTENT).build(); } this.slf4Jlogger.debug("Retrieving terms with IDs: [{}]", termIds); final JSONObject rep = new JSONObject() .put(ROWS, this.createRows(termIds)) .put(LINKS, this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return Response.ok(rep, MediaType.APPLICATION_JSON_TYPE).build(); }
DefaultVocabularyTermsResolveResource extends XWikiResource implements VocabularyTermsResolveResource { @Override public Response resolveTerms() { final Request request = this.container.getRequest(); final List<Object> termIds = request.getProperties(TERM_ID); if (CollectionUtils.isEmpty(termIds)) { this.slf4Jlogger.info("No content provided."); return Response.status(Response.Status.NO_CONTENT).build(); } this.slf4Jlogger.debug("Retrieving terms with IDs: [{}]", termIds); final JSONObject rep = new JSONObject() .put(ROWS, this.createRows(termIds)) .put(LINKS, this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return Response.ok(rep, MediaType.APPLICATION_JSON_TYPE).build(); } }
DefaultVocabularyTermsResolveResource extends XWikiResource implements VocabularyTermsResolveResource { @Override public Response resolveTerms() { final Request request = this.container.getRequest(); final List<Object> termIds = request.getProperties(TERM_ID); if (CollectionUtils.isEmpty(termIds)) { this.slf4Jlogger.info("No content provided."); return Response.status(Response.Status.NO_CONTENT).build(); } this.slf4Jlogger.debug("Retrieving terms with IDs: [{}]", termIds); final JSONObject rep = new JSONObject() .put(ROWS, this.createRows(termIds)) .put(LINKS, this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return Response.ok(rep, MediaType.APPLICATION_JSON_TYPE).build(); }  }
DefaultVocabularyTermsResolveResource extends XWikiResource implements VocabularyTermsResolveResource { @Override public Response resolveTerms() { final Request request = this.container.getRequest(); final List<Object> termIds = request.getProperties(TERM_ID); if (CollectionUtils.isEmpty(termIds)) { this.slf4Jlogger.info("No content provided."); return Response.status(Response.Status.NO_CONTENT).build(); } this.slf4Jlogger.debug("Retrieving terms with IDs: [{}]", termIds); final JSONObject rep = new JSONObject() .put(ROWS, this.createRows(termIds)) .put(LINKS, this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return Response.ok(rep, MediaType.APPLICATION_JSON_TYPE).build(); }  @Override Response resolveTerms(); }
DefaultVocabularyTermsResolveResource extends XWikiResource implements VocabularyTermsResolveResource { @Override public Response resolveTerms() { final Request request = this.container.getRequest(); final List<Object> termIds = request.getProperties(TERM_ID); if (CollectionUtils.isEmpty(termIds)) { this.slf4Jlogger.info("No content provided."); return Response.status(Response.Status.NO_CONTENT).build(); } this.slf4Jlogger.debug("Retrieving terms with IDs: [{}]", termIds); final JSONObject rep = new JSONObject() .put(ROWS, this.createRows(termIds)) .put(LINKS, this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return Response.ok(rep, MediaType.APPLICATION_JSON_TYPE).build(); }  @Override Response resolveTerms();  }