@Test public void updateAttachmentContentRequest_withEmptyAttachmentId_throwsIllegalArgumentException() { this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("attachmentId must be set"); this.httpRequestFactory.updateAttachmentContentRequest("1234", "", new ByteArrayInputStream("hello".getBytes())); }
HttpPost updateAttachmentContentRequest(String contentId, String attachmentId, InputStream attachmentContent) { assertMandatoryParameter(isNotBlank(contentId), "contentId"); assertMandatoryParameter(isNotBlank(attachmentId), "attachmentId"); assertMandatoryParameter(attachmentContent != null, "attachmentContent"); HttpPost attachmentPostRequest = new HttpPost(this.confluenceRestApiEndpoint + "/content/" + contentId + "/child/attachment/" + attachmentId + "/data"); attachmentPostRequest.addHeader(new BasicHeader("X-Atlassian-Token", "no-check")); HttpEntity multipartEntity = multipartEntity(null, attachmentContent); attachmentPostRequest.setEntity(multipartEntity); return attachmentPostRequest; }
HttpRequestFactory { HttpPost updateAttachmentContentRequest(String contentId, String attachmentId, InputStream attachmentContent) { assertMandatoryParameter(isNotBlank(contentId), "contentId"); assertMandatoryParameter(isNotBlank(attachmentId), "attachmentId"); assertMandatoryParameter(attachmentContent != null, "attachmentContent"); HttpPost attachmentPostRequest = new HttpPost(this.confluenceRestApiEndpoint + "/content/" + contentId + "/child/attachment/" + attachmentId + "/data"); attachmentPostRequest.addHeader(new BasicHeader("X-Atlassian-Token", "no-check")); HttpEntity multipartEntity = multipartEntity(null, attachmentContent); attachmentPostRequest.setEntity(multipartEntity); return attachmentPostRequest; } }
HttpRequestFactory { HttpPost updateAttachmentContentRequest(String contentId, String attachmentId, InputStream attachmentContent) { assertMandatoryParameter(isNotBlank(contentId), "contentId"); assertMandatoryParameter(isNotBlank(attachmentId), "attachmentId"); assertMandatoryParameter(attachmentContent != null, "attachmentContent"); HttpPost attachmentPostRequest = new HttpPost(this.confluenceRestApiEndpoint + "/content/" + contentId + "/child/attachment/" + attachmentId + "/data"); attachmentPostRequest.addHeader(new BasicHeader("X-Atlassian-Token", "no-check")); HttpEntity multipartEntity = multipartEntity(null, attachmentContent); attachmentPostRequest.setEntity(multipartEntity); return attachmentPostRequest; } HttpRequestFactory(String rootConfluenceUrl); }
HttpRequestFactory { HttpPost updateAttachmentContentRequest(String contentId, String attachmentId, InputStream attachmentContent) { assertMandatoryParameter(isNotBlank(contentId), "contentId"); assertMandatoryParameter(isNotBlank(attachmentId), "attachmentId"); assertMandatoryParameter(attachmentContent != null, "attachmentContent"); HttpPost attachmentPostRequest = new HttpPost(this.confluenceRestApiEndpoint + "/content/" + contentId + "/child/attachment/" + attachmentId + "/data"); attachmentPostRequest.addHeader(new BasicHeader("X-Atlassian-Token", "no-check")); HttpEntity multipartEntity = multipartEntity(null, attachmentContent); attachmentPostRequest.setEntity(multipartEntity); return attachmentPostRequest; } 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); }
HttpRequestFactory { HttpPost updateAttachmentContentRequest(String contentId, String attachmentId, InputStream attachmentContent) { assertMandatoryParameter(isNotBlank(contentId), "contentId"); assertMandatoryParameter(isNotBlank(attachmentId), "attachmentId"); assertMandatoryParameter(attachmentContent != null, "attachmentContent"); HttpPost attachmentPostRequest = new HttpPost(this.confluenceRestApiEndpoint + "/content/" + contentId + "/child/attachment/" + attachmentId + "/data"); attachmentPostRequest.addHeader(new BasicHeader("X-Atlassian-Token", "no-check")); HttpEntity multipartEntity = multipartEntity(null, attachmentContent); attachmentPostRequest.setEntity(multipartEntity); return attachmentPostRequest; } 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);  }