diff --git a/rest-client/src/main/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImpl.java b/rest-client/src/main/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImpl.java index 0cb4d36..f9737c1 100644 --- a/rest-client/src/main/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImpl.java +++ b/rest-client/src/main/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImpl.java @@ -142,6 +142,18 @@ public Optional getTemplatePublished(long templateId) throws ApiExc @Override public void save(@Nonnull CmsSection section) throws ApiException { + if (section instanceof CmsBuiltinSection) { + saveBuiltinSection((CmsBuiltinSection) section); + } else { + saveSection(section); + } + } + + private void saveBuiltinSection(CmsBuiltinSection builtinSection) { + throw new UnsupportedOperationException("CmsBuiltinSection cannot be modified"); + } + + private void saveSection(CmsSection section) throws ApiException { Section restSection = SECTION_MAPPER.toRest(section); if (section.getId() == null) { if (StringUtils.isBlank(restSection.getTitle()) diff --git a/rest-client/src/main/java/com/fwmotion/threescale/cms/mappers/CmsBuiltinSectionMapper.java b/rest-client/src/main/java/com/fwmotion/threescale/cms/mappers/CmsBuiltinSectionMapper.java new file mode 100644 index 0000000..6a7b7e3 --- /dev/null +++ b/rest-client/src/main/java/com/fwmotion/threescale/cms/mappers/CmsBuiltinSectionMapper.java @@ -0,0 +1,14 @@ +package com.fwmotion.threescale.cms.mappers; + +import com.fwmotion.threescale.cms.model.CmsBuiltinSection; +import com.redhat.threescale.rest.cms.model.BuiltinSection; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper +public interface CmsBuiltinSectionMapper { + + @Mapping(target = "path", source = "partialPath") + CmsBuiltinSection fromRest(BuiltinSection builtinSection); + +} diff --git a/rest-client/src/main/java/com/fwmotion/threescale/cms/mixins/SectionListMixIn.java b/rest-client/src/main/java/com/fwmotion/threescale/cms/mixins/SectionListMixIn.java index c602296..6a8a0aa 100644 --- a/rest-client/src/main/java/com/fwmotion/threescale/cms/mixins/SectionListMixIn.java +++ b/rest-client/src/main/java/com/fwmotion/threescale/cms/mixins/SectionListMixIn.java @@ -1,7 +1,9 @@ package com.fwmotion.threescale.cms.mixins; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.redhat.threescale.rest.cms.model.BuiltinSection; import com.redhat.threescale.rest.cms.model.Section; import jakarta.xml.bind.annotation.XmlElement; @@ -10,10 +12,22 @@ /** * @see com.redhat.threescale.rest.cms.model.SectionList */ +@JsonDeserialize(as = SectionMergingList.class) public interface SectionListMixIn { + String ELEMENT_NAME_BUILTIN_SECTION = "builtin_section"; String ELEMENT_NAME_SECTION = "section"; + @JsonProperty(ELEMENT_NAME_SECTION) + @XmlElement(name = ELEMENT_NAME_SECTION) + @JacksonXmlElementWrapper(useWrapping = false, localName = ELEMENT_NAME_BUILTIN_SECTION) + List getBuiltinSections(); + + @JsonProperty(ELEMENT_NAME_BUILTIN_SECTION) + @XmlElement(name = ELEMENT_NAME_BUILTIN_SECTION) + @JacksonXmlElementWrapper(useWrapping = false, localName = ELEMENT_NAME_BUILTIN_SECTION) + void setBuiltinSections(List sections); + @JsonProperty(ELEMENT_NAME_SECTION) @XmlElement(name = ELEMENT_NAME_SECTION) @JacksonXmlElementWrapper(useWrapping = false, localName = ELEMENT_NAME_SECTION) diff --git a/rest-client/src/main/java/com/fwmotion/threescale/cms/mixins/SectionMergingList.java b/rest-client/src/main/java/com/fwmotion/threescale/cms/mixins/SectionMergingList.java new file mode 100644 index 0000000..543a09a --- /dev/null +++ b/rest-client/src/main/java/com/fwmotion/threescale/cms/mixins/SectionMergingList.java @@ -0,0 +1,40 @@ +package com.fwmotion.threescale.cms.mixins; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.redhat.threescale.rest.cms.model.BuiltinSection; +import com.redhat.threescale.rest.cms.model.Section; +import com.redhat.threescale.rest.cms.model.SectionList; +import jakarta.xml.bind.annotation.XmlElement; + +import java.util.List; + +/** + * This is used for deserialization to facilitate interlaced unwrapped lists. + * Per + * jackson-dataformat-xml Issue #275, + * interlaced unwrapped lists is not supported, so this class will be used + * as a workaround to merge the lists as they're "set" into the object. + * + * @see SectionListMixIn + * @see SectionList + */ +public class SectionMergingList extends SectionList { + + @JsonProperty(SectionListMixIn.ELEMENT_NAME_BUILTIN_SECTION) + @XmlElement(name = SectionListMixIn.ELEMENT_NAME_BUILTIN_SECTION) + @JacksonXmlElementWrapper(useWrapping = false, localName = SectionListMixIn.ELEMENT_NAME_BUILTIN_SECTION) + @Override + public void setBuiltinSections(List builtinSections) { + builtinSections.forEach(super::addBuiltinSectionsItem); + } + + @JsonProperty(SectionListMixIn.ELEMENT_NAME_BUILTIN_SECTION) + @XmlElement(name = SectionListMixIn.ELEMENT_NAME_BUILTIN_SECTION) + @JacksonXmlElementWrapper(useWrapping = false, localName = SectionListMixIn.ELEMENT_NAME_BUILTIN_SECTION) + @Override + public void setSections(List
sections) { + sections.forEach(super::addSectionsItem); + } + +} diff --git a/rest-client/src/main/java/com/fwmotion/threescale/cms/model/CmsBuiltinSection.java b/rest-client/src/main/java/com/fwmotion/threescale/cms/model/CmsBuiltinSection.java new file mode 100644 index 0000000..48087fa --- /dev/null +++ b/rest-client/src/main/java/com/fwmotion/threescale/cms/model/CmsBuiltinSection.java @@ -0,0 +1,9 @@ +package com.fwmotion.threescale.cms.model; + +/** + * Subclass of {@link CmsSection} to differentiate builtin_section from section. + *

+ * The properties all appear to remain identical. + */ +public class CmsBuiltinSection extends CmsSection { +} diff --git a/rest-client/src/main/java/com/fwmotion/threescale/cms/model/CmsSection.java b/rest-client/src/main/java/com/fwmotion/threescale/cms/model/CmsSection.java index adb6856..7177e8c 100644 --- a/rest-client/src/main/java/com/fwmotion/threescale/cms/model/CmsSection.java +++ b/rest-client/src/main/java/com/fwmotion/threescale/cms/model/CmsSection.java @@ -6,7 +6,7 @@ import java.time.OffsetDateTime; -public class CmsSection implements CmsObject{ +public class CmsSection implements CmsObject { private OffsetDateTime createdAt; private OffsetDateTime updatedAt; @@ -93,9 +93,7 @@ public void setPath(String path) { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof CmsSection)) return false; - - CmsSection that = (CmsSection) o; + if (!(o instanceof CmsSection that)) return false; return new EqualsBuilder().append(getId(), that.getId()).isEquals(); } diff --git a/rest-client/src/main/java/com/fwmotion/threescale/cms/support/PagedSectionsSpliterator.java b/rest-client/src/main/java/com/fwmotion/threescale/cms/support/PagedSectionsSpliterator.java index eef97f0..400fa40 100644 --- a/rest-client/src/main/java/com/fwmotion/threescale/cms/support/PagedSectionsSpliterator.java +++ b/rest-client/src/main/java/com/fwmotion/threescale/cms/support/PagedSectionsSpliterator.java @@ -1,5 +1,6 @@ package com.fwmotion.threescale.cms.support; +import com.fwmotion.threescale.cms.mappers.CmsBuiltinSectionMapper; import com.fwmotion.threescale.cms.mappers.CmsSectionMapper; import com.fwmotion.threescale.cms.model.CmsSection; import com.redhat.threescale.rest.cms.ApiException; @@ -14,10 +15,12 @@ import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; public class PagedSectionsSpliterator extends AbstractPagedRestApiSpliterator { private static final CmsSectionMapper SECTION_MAPPER = Mappers.getMapper(CmsSectionMapper.class); + private static final CmsBuiltinSectionMapper BUILTIN_SECTION_MAPPER = Mappers.getMapper(CmsBuiltinSectionMapper.class); private final SectionsApi sectionsApi; @@ -47,10 +50,15 @@ protected Collection getPage(@PositiveOrZero int pageNumber, try { SectionList sectionList = sectionsApi.listSections(pageNumber, pageSize); - List resultPage = ListUtils.emptyIfNull(sectionList.getSections()) - .stream() - .map(SECTION_MAPPER::fromRest) - .collect(Collectors.toList()); + List resultPage = + Stream.concat( + ListUtils.emptyIfNull(sectionList.getBuiltinSections()) + .stream() + .map(BUILTIN_SECTION_MAPPER::fromRest), + ListUtils.emptyIfNull(sectionList.getSections()) + .stream() + .map(SECTION_MAPPER::fromRest) + ).collect(Collectors.toList()); validateResultPageSize( "section", diff --git a/rest-client/src/main/resources/api-spec/3scale-cms.yaml b/rest-client/src/main/resources/api-spec/3scale-cms.yaml index eff5447..1194b02 100644 --- a/rest-client/src/main/resources/api-spec/3scale-cms.yaml +++ b/rest-client/src/main/resources/api-spec/3scale-cms.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: 3scale CMS API - version: '2.12' + version: '2.14' description: 3scale's undocumented content management system API servers: - url: 'https://{tenant-name}-admin.{ocp-wildcard-url}' @@ -22,7 +22,7 @@ paths: - name: page description: | The number for the page of results to retrieve, starting from page 1; - defautls to 1 + defaults to 1 schema: type: integer minimum: 1 @@ -170,7 +170,7 @@ paths: - Sections responses: '200': - $ref: '#/components/responses/SectionResponse' + $ref: '#/components/responses/SectionTypeResponse' operationId: get-section summary: Get Section description: Get section descriptor @@ -216,7 +216,7 @@ paths: - Sections responses: '200': - $ref: '#/components/responses/SectionResponse' + $ref: '#/components/responses/SectionTypeResponse' operationId: get-section-by-system-name summary: Get Section by System Name description: Get section descriptor @@ -996,6 +996,23 @@ components: type: integer format: int64 example: 3 + BuiltinSection: + description: Builtin section within 3scale CMS + allOf: + - $ref: '#/components/schemas/Section' + xml: + name: builtin_section + example: |- + + 1974454 + 2016-10-29T17:55:09-05:00 + 2020-07-22T16:08:40-05:00 + Root + root + true + + / + Section: description: Section within 3scale CMS allOf: @@ -1047,6 +1064,13 @@ components: allOf: - $ref: '#/components/schemas/ListPaginationAttributes' - properties: + builtinSections: + type: array + items: + $ref: '#/components/schemas/BuiltinSection' + xml: + name: builtin_section + wrapped: false sections: type: array items: @@ -1059,7 +1083,7 @@ components: example: |- -

+ 30 2022-03-05T04:48:27Z 2022-03-18T06:31:57Z @@ -1260,6 +1284,10 @@ components: search
+ SectionType: + oneOf: + - $ref: '#/components/schemas/BuiltinSection' + - $ref: '#/components/schemas/Section' SectionUpdatableFields: description: Fields that may be modified after section creation properties: @@ -1629,14 +1657,7 @@ components: maxLength: 255 responses: EmptyResponse: - content: - application/xml: - schema: - default: '' - maxLength: 0 - minLength: 0 - type: string - description: Response indicating successful deletion + description: Response with no body; eg, to indicate successful deletion ErrorHashResponse: content: application/xml: @@ -1691,6 +1712,12 @@ components: schema: $ref: '#/components/schemas/Section' description: Response containing a single `Section` + SectionTypeResponse: + content: + application/xml: + schema: + $ref: '#/components/schemas/SectionType' + description: Response containing a single `SectionType` securitySchemes: provider_key: type: apiKey diff --git a/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplIntegrationTest.java b/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplIntegrationTest.java index fdc8a3f..718eed5 100644 --- a/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplIntegrationTest.java +++ b/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplIntegrationTest.java @@ -67,7 +67,8 @@ void listAllCmsObjects() { assertThat(result, hasSize(97)); assertThat(result, hasItems( FilesApiTestSupport.FAVICON_FILE_MATCHER, - SectionsApiTestSupport.ROOT_SECTION_MATCHER, + SectionsApiTestSupport.ROOT_BUILTIN_SECTION_MATCHER, + SectionsApiTestSupport.CSS_SECTION_MATCHER, TemplatesApiTestSupport.MAIN_LAYOUT_MATCHER )); } @@ -80,4 +81,5 @@ void getFileContent() throws Exception { assertThat(result.get(), inputStreamContents(equalTo("This is a test value.\n"))); } + } diff --git a/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplUnitTest.java b/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplUnitTest.java index 6544268..5fc9615 100644 --- a/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplUnitTest.java +++ b/rest-client/src/test/java/com/fwmotion/threescale/cms/ThreescaleCmsClientImplUnitTest.java @@ -41,7 +41,7 @@ import static com.fwmotion.threescale.cms.matchers.InputStreamContentsMatcher.inputStreamContents; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.same; import static org.mockito.BDDMockito.given; @@ -87,7 +87,7 @@ void setUp() { @Test void testStreamAllCmsObjects() throws Exception { - sectionsApiTestSupport.givenListSectionOnlyRoot(); + sectionsApiTestSupport.givenListSectionRootAndCss(); filesApiTestSupport.givenListFilesOnlyFavicon(); templatesApiTestSupport.givenListTemplatesOnlyMainLayout(); @@ -99,7 +99,8 @@ void testStreamAllCmsObjects() throws Exception { templatesApiTestSupport.thenOnlyListTemplatesCalled(); assertThat(result, contains( - SectionsApiTestSupport.ROOT_SECTION_MATCHER, + SectionsApiTestSupport.ROOT_BUILTIN_SECTION_MATCHER, + SectionsApiTestSupport.CSS_SECTION_MATCHER, FilesApiTestSupport.FAVICON_FILE_MATCHER, TemplatesApiTestSupport.MAIN_LAYOUT_MATCHER)); } @@ -117,7 +118,7 @@ void listAllCmsObjects() throws Exception { templatesApiTestSupport.thenOnlyListTemplatesCalled(); assertThat(result, contains( - SectionsApiTestSupport.ROOT_SECTION_MATCHER, + SectionsApiTestSupport.ROOT_BUILTIN_SECTION_MATCHER, FilesApiTestSupport.FAVICON_FILE_MATCHER, TemplatesApiTestSupport.MAIN_LAYOUT_MATCHER)); } @@ -133,7 +134,7 @@ void streamSections() throws Exception { then(filesApi).shouldHaveNoInteractions(); then(templatesApi).shouldHaveNoInteractions(); - assertThat(result, contains(SectionsApiTestSupport.ROOT_SECTION_MATCHER)); + assertThat(result, contains(SectionsApiTestSupport.ROOT_BUILTIN_SECTION_MATCHER)); } @Test @@ -146,7 +147,7 @@ void listSections() throws Exception { then(filesApi).shouldHaveNoInteractions(); then(templatesApi).shouldHaveNoInteractions(); - assertThat(result, contains(SectionsApiTestSupport.ROOT_SECTION_MATCHER)); + assertThat(result, contains(SectionsApiTestSupport.ROOT_BUILTIN_SECTION_MATCHER)); } @Test @@ -194,7 +195,7 @@ void getFileContent_ByIdNoAccessCode() throws Exception { // And any direct HTTP request will return a result given(httpClientMock.execute(ArgumentMatchers.any(HttpUriRequest.class), ArgumentMatchers.>any())) - .willAnswer(invocation -> ((HttpClientResponseHandler)invocation.getArgument(1)) + .willAnswer(invocation -> ((HttpClientResponseHandler) invocation.getArgument(1)) .handleResponse(httpResponseMock)); BasicHttpEntity responseEntity = new BasicHttpEntity( @@ -256,7 +257,7 @@ void getFileContent_ByIdWithAccessCode() throws Exception { // And any direct HTTP request will return a result given(httpClientMock.execute(ArgumentMatchers.any(HttpUriRequest.class), ArgumentMatchers.>any())) - .willAnswer(invocation -> ((HttpClientResponseHandler)invocation.getArgument(1)) + .willAnswer(invocation -> ((HttpClientResponseHandler) invocation.getArgument(1)) .handleResponse(httpResponseMock)); BasicHttpEntity responseEntity = new BasicHttpEntity( @@ -318,7 +319,7 @@ void getFileContent_ByCmsFileNoAccessCode() throws Exception { // And any direct HTTP request will return a result given(httpClientMock.execute(ArgumentMatchers.any(HttpUriRequest.class), ArgumentMatchers.>any())) - .willAnswer(invocation -> ((HttpClientResponseHandler)invocation.getArgument(1)) + .willAnswer(invocation -> ((HttpClientResponseHandler) invocation.getArgument(1)) .handleResponse(httpResponseMock)); BasicHttpEntity responseEntity = new BasicHttpEntity( @@ -383,7 +384,7 @@ void getFileContent_ByCmsFileWithAccessCode() throws Exception { // And any direct HTTP request will return a result given(httpClientMock.execute(ArgumentMatchers.any(HttpUriRequest.class), ArgumentMatchers.>any())) - .willAnswer(invocation -> ((HttpClientResponseHandler)invocation.getArgument(1)) + .willAnswer(invocation -> ((HttpClientResponseHandler) invocation.getArgument(1)) .handleResponse(httpResponseMock)); BasicHttpEntity responseEntity = new BasicHttpEntity( @@ -640,6 +641,30 @@ void save_NewSectionWithTitle() throws Exception { assertThat(newSection.getId(), is(32L)); } + @Test + void save_UpdateBuiltinSectionUnsupported() { + // Given a CmsBuiltinSection object to update + CmsBuiltinSection builtinSection = new CmsBuiltinSection(); + builtinSection.setId(30L); + builtinSection.setSystemName("root"); + builtinSection.setParentId(32L); + + // When the CmsBuiltinSection is saved + UnsupportedOperationException thrown = assertThrows( + UnsupportedOperationException.class, + () -> threescaleCmsClient.save(builtinSection) + ); + + // Then an exception should have been thrown because builtin sections + // cannot be created or updated + assertNotNull(thrown); + + // And no APIs should have been called + then(sectionsApi).shouldHaveNoInteractions(); + then(filesApi).shouldHaveNoInteractions(); + then(templatesApi).shouldHaveNoInteractions(); + } + @Test void save_UpdatedSection() throws Exception { // Given a CmsSection object with an ID already diff --git a/rest-client/src/test/java/com/fwmotion/threescale/cms/matchers/CmsBuiltinSectionMatcher.java b/rest-client/src/test/java/com/fwmotion/threescale/cms/matchers/CmsBuiltinSectionMatcher.java new file mode 100644 index 0000000..697edd7 --- /dev/null +++ b/rest-client/src/test/java/com/fwmotion/threescale/cms/matchers/CmsBuiltinSectionMatcher.java @@ -0,0 +1,39 @@ +package com.fwmotion.threescale.cms.matchers; + +import com.fwmotion.threescale.cms.model.CmsObject; +import com.fwmotion.threescale.cms.model.CmsSection; +import com.redhat.threescale.rest.cms.model.BuiltinSection; +import jakarta.annotation.Nonnull; +import org.hamcrest.Description; + +public class CmsBuiltinSectionMatcher extends CmsObjectMatcher { + + private final BuiltinSection expected; + + public CmsBuiltinSectionMatcher(@Nonnull BuiltinSection expected) { + super( + expected.getId(), + expected.getCreatedAt(), + expected.getUpdatedAt() + ); + this.expected = expected; + } + + @Override + public boolean matchesSafely(@Nonnull CmsObject actual) { + if (!(actual instanceof CmsSection actualSection)) { + return false; + } + + return super.matchesSafely(actual) + && actualMatchesExpected(expected.getParentId(), actualSection.getParentId()) + && actualMatchesExpected(expected.getSystemName(), actualSection.getSystemName()) + && actualMatchesExpected(expected.getPartialPath(), actualSection.getPath()) + && actualMatchesExpected(expected.getPublic(), actualSection.getPublic()); + } + + @Override + public void describeTo(@Nonnull Description description) { + description.appendText("CmsBuiltinSection from " + expected); + } +} diff --git a/rest-client/src/test/java/com/fwmotion/threescale/cms/testsupport/SectionsApiTestSupport.java b/rest-client/src/test/java/com/fwmotion/threescale/cms/testsupport/SectionsApiTestSupport.java index b0c2c88..c3a838a 100644 --- a/rest-client/src/test/java/com/fwmotion/threescale/cms/testsupport/SectionsApiTestSupport.java +++ b/rest-client/src/test/java/com/fwmotion/threescale/cms/testsupport/SectionsApiTestSupport.java @@ -1,9 +1,11 @@ package com.fwmotion.threescale.cms.testsupport; +import com.fwmotion.threescale.cms.matchers.CmsBuiltinSectionMatcher; import com.fwmotion.threescale.cms.matchers.CmsSectionMatcher; import com.fwmotion.threescale.cms.model.CmsObject; import com.redhat.threescale.rest.cms.ApiException; import com.redhat.threescale.rest.cms.api.SectionsApi; +import com.redhat.threescale.rest.cms.model.BuiltinSection; import com.redhat.threescale.rest.cms.model.Section; import com.redhat.threescale.rest.cms.model.SectionList; import org.hamcrest.Matcher; @@ -20,7 +22,7 @@ public class SectionsApiTestSupport { - public static final Section ROOT_SECTION = new Section() + public static final BuiltinSection ROOT_BUILTIN_SECTION = new BuiltinSection() .id(30L) .parentId(null) .systemName("root") @@ -30,7 +32,18 @@ public class SectionsApiTestSupport { .createdAt(OffsetDateTime.of(2022, 3, 5, 4, 48, 27, 0, ZoneOffset.UTC)) .updatedAt(OffsetDateTime.of(2022, 3, 18, 6, 31, 57, 0, ZoneOffset.UTC)); - public static final Matcher ROOT_SECTION_MATCHER = new CmsSectionMatcher(ROOT_SECTION); + public static final Section CSS_SECTION = new Section() + .id(32L) + .parentId(30L) + .systemName("css") + .title("css") + .partialPath("/css") + ._public(true) + .createdAt(OffsetDateTime.of(2022, 3, 5, 4, 48, 27, 0, ZoneOffset.UTC)) + .updatedAt(OffsetDateTime.of(2022, 3, 5, 4, 48, 27, 0, ZoneOffset.UTC)); + + public static final Matcher ROOT_BUILTIN_SECTION_MATCHER = new CmsBuiltinSectionMatcher(ROOT_BUILTIN_SECTION); + public static final Matcher CSS_SECTION_MATCHER = new CmsSectionMatcher(CSS_SECTION); private final SectionsApi sectionsApi; @@ -44,7 +57,23 @@ public void givenListSectionOnlyRoot() throws ApiException { .currentPage(1) .totalPages(1) .totalEntries(1) - .addSectionsItem(ROOT_SECTION)); + .addBuiltinSectionsItem(ROOT_BUILTIN_SECTION)); + + given(sectionsApi.listSections(eq(2), anyInt())) + .willReturn(new SectionList() + .currentPage(2) + .totalPages(1) + .totalEntries(1)); + } + + public void givenListSectionRootAndCss() throws ApiException { + given(sectionsApi.listSections(eq(1), anyInt())) + .willReturn(new SectionList() + .currentPage(1) + .totalPages(1) + .totalEntries(2) + .addBuiltinSectionsItem(ROOT_BUILTIN_SECTION) + .addSectionsItem(CSS_SECTION)); given(sectionsApi.listSections(eq(2), anyInt())) .willReturn(new SectionList() diff --git a/rest-client/src/test/resources/imposter/responses/list-sections-1.xml b/rest-client/src/test/resources/imposter/responses/list-sections-1.xml index 96be12e..1312fbb 100644 --- a/rest-client/src/test/resources/imposter/responses/list-sections-1.xml +++ b/rest-client/src/test/resources/imposter/responses/list-sections-1.xml @@ -1,6 +1,6 @@ -
+ 30 2022-03-05T04:48:27Z 2022-03-18T06:31:57Z @@ -9,7 +9,7 @@ Root root -
+
31 2022-03-05T04:48:27Z