HttpRequestFactory { HttpGet getChildPagesByIdRequest(String parentContentId, Integer limit, Integer start, String expandOptions) { assertMandatoryParameter(isNotBlank(parentContentId), "parentContentId"); URIBuilder uriBuilder = createUriBuilder(this.confluenceRestApiEndpoint + "/content/" + parentContentId + "/child/page"); if (limit != null) { uriBuilder.addParameter("limit", limit.toString()); } if (start != null) { uriBuilder.addParameter("start", start.toString()); } if (isNotBlank(expandOptions)) { uriBuilder.addParameter("expand", expandOptions); } HttpGet getChildPagesByIdRequest; try { getChildPagesByIdRequest = new HttpGet(uriBuilder.build().toString()); } catch (URISyntaxException e) { throw new RuntimeException("Invalid URL", e); } return getChildPagesByIdRequest; } 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 getChildPagesByIdRequest_withMinimalParameters_returnsValidHttpGet() { String parentContentId = "1234"; HttpGet getChildPagesByIdRequest = this.httpRequestFactory.getChildPagesByIdRequest(parentContentId, null, null, null); assertThat(getChildPagesByIdRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + parentContentId + "/child/page")); }
@Test public void getChildPagesByIdRequest_withBlankParentContentId_throwsIllegalArgumentException() { this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("parentContentId must be set"); this.httpRequestFactory.getChildPagesByIdRequest("", null, null, null); }
@Test public void getChildPagesByIdRequest_withLimit_returnsHttpGetWithLimit() { String parentContentId = "1234"; int limit = 5; HttpGet getChildPagesByIdRequest = this.httpRequestFactory.getChildPagesByIdRequest(parentContentId, limit, null, null); assertThat(getChildPagesByIdRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + parentContentId + "/child/page?limit=" + limit)); }
@Test public void getChildPagesByIdRequest_withPageNumber_returnsHttpGetWithLimit() { String parentContentId = "1234"; int start = 5; HttpGet getChildPagesByIdRequest = this.httpRequestFactory.getChildPagesByIdRequest(parentContentId, null, start, null); assertThat(getChildPagesByIdRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + parentContentId + "/child/page?start=" + start)); }
@Test public void getChildPagesByIdRequest_withExpandOptions_returnsHttpGetWithExpandOption() { String parentContentId = "1234"; String expandOptions = "version"; HttpGet getChildPagesByIdRequest = this.httpRequestFactory.getChildPagesByIdRequest(parentContentId, null, null, expandOptions); assertThat(getChildPagesByIdRequest.getURI().toString(), is(CONFLUENCE_REST_API_ENDPOINT + "/content/" + parentContentId + "/child/page?expand=" + expandOptions)); }
@Test public void getChildPagesByIdRequest_withLimitAndPageNumber_returnsHttpGetWithPageNumberAndLimit() { String parentContentId = "1234"; int limit = 10; int start = 5; HttpGet getChildPagesByIdRequest = this.httpRequestFactory.getChildPagesByIdRequest(parentContentId, limit, start, null); assertThat(getChildPagesByIdRequest.getURI().toString(), containsString("limit=" + limit)); assertThat(getChildPagesByIdRequest.getURI().toString(), containsString("start=" + start)); }