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