HttpRequestFactory { HttpPost addLabelsRequest(String contentId, List<String> labels) { assertMandatoryParameter(isNotBlank(contentId), "contentId"); assertMandatoryParameter(!labels.isEmpty(), "labels"); List<Label> payload = labels.stream().map(Label::new).collect(toList()); HttpPost addLabelsRequest = new HttpPost(this.confluenceRestApiEndpoint + "/content/" + contentId + "/label"); addLabelsRequest.setEntity(httpEntityWithJsonPayload(payload)); addLabelsRequest.addHeader(APPLICATION_JSON_UTF8_HEADER); return addLabelsRequest; } HttpRequestFactory(String rootConfluenceUrl); HttpGet getAttachmentsRequest(String contentId, Integer limit, Integer start, String expandOptions); HttpGet getAttachmentContentRequest(String relativeDownloadLink); HttpGet getPropertyByKeyRequest(String contentId, String key); HttpDelete deletePropertyByKeyRequest(String contentId, String key); HttpPost setPropertyByKeyRequest(String contentId, String key, String value);  }
@Test public void addLabels_withValidParameters_returnsHttpPostRequest() { String contentId = "1234"; List<String> labels = singletonList("foo"); HttpPost addLabelsRequest = this.httpRequestFactory.addLabelsRequest(contentId, labels); assertThat(addLabelsRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + contentId + "/label")); }