HttpRequestFactory { public HttpPost setPropertyByKeyRequest(String contentId, String key, String value) { assertMandatoryParameter(isNotBlank(contentId), "contentId"); assertMandatoryParameter(isNotBlank(key), "key"); assertMandatoryParameter(isNotBlank(value), "value"); PropertyPayload propertyPayload = new PropertyPayload(); propertyPayload.setKey(key); propertyPayload.setValue(value); HttpPost postRequest = new HttpPost(this.confluenceRestApiEndpoint + "/content/" + contentId + "/property"); postRequest.setEntity(httpEntityWithJsonPayload(propertyPayload)); postRequest.addHeader(APPLICATION_JSON_UTF8_HEADER); return postRequest; } 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 setPropertyByKeyRequest_withValidParameters_returnsHttpPostRequest() throws Exception { String contentId = "1234"; String key = "content-hash"; String value = "38495fsj98wgh"; HttpPost setPropertyByKeyRequest = this.httpRequestFactory.setPropertyByKeyRequest(contentId, key, value); assertThat(setPropertyByKeyRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + contentId + "/property")); assertThat(setPropertyByKeyRequest.getFirstHeader("Content-Type").getValue(), is(APPLICATION_JSON_UTF8)); String jsonPayload = inputStreamAsString(setPropertyByKeyRequest.getEntity().getContent(), UTF_8); String expectedJsonPayload = fileContent(Paths.get(CLASS_LOCATION, "set-property-by-key-request-payload.json").toString(), UTF_8); assertThat(jsonPayload, isSameJsonAs(expectedJsonPayload)); }