|
| 1 | +package com.box.sdkgen.hubdocument; |
| 2 | + |
| 3 | +import static com.box.sdkgen.commons.CommonsManager.getDefaultClientWithUserSubject; |
| 4 | +import static com.box.sdkgen.internal.utils.UtilsManager.convertToString; |
| 5 | +import static com.box.sdkgen.internal.utils.UtilsManager.getEnvVar; |
| 6 | +import static com.box.sdkgen.internal.utils.UtilsManager.getUuid; |
| 7 | + |
| 8 | +import com.box.sdkgen.client.BoxClient; |
| 9 | +import com.box.sdkgen.managers.hubdocument.GetHubDocumentBlocksV2025R0QueryParams; |
| 10 | +import com.box.sdkgen.managers.hubdocument.GetHubDocumentPagesV2025R0QueryParams; |
| 11 | +import com.box.sdkgen.schemas.v2025r0.hubcreaterequestv2025r0.HubCreateRequestV2025R0; |
| 12 | +import com.box.sdkgen.schemas.v2025r0.hubdocumentblockentryv2025r0.HubDocumentBlockEntryV2025R0; |
| 13 | +import com.box.sdkgen.schemas.v2025r0.hubdocumentblocksv2025r0.HubDocumentBlocksV2025R0; |
| 14 | +import com.box.sdkgen.schemas.v2025r0.hubdocumentpagesv2025r0.HubDocumentPagesV2025R0; |
| 15 | +import com.box.sdkgen.schemas.v2025r0.hubdocumentpagev2025r0.HubDocumentPageV2025R0; |
| 16 | +import com.box.sdkgen.schemas.v2025r0.hubv2025r0.HubV2025R0; |
| 17 | +import org.junit.jupiter.api.Test; |
| 18 | + |
| 19 | +public class HubDocumentITest { |
| 20 | + |
| 21 | + private static final BoxClient client = getDefaultClientWithUserSubject(getEnvVar("USER_ID")); |
| 22 | + |
| 23 | + @Test |
| 24 | + public void testGetHubDocumentPagesAndBlocks() { |
| 25 | + String hubTitle = getUuid(); |
| 26 | + HubV2025R0 createdHub = |
| 27 | + client.getHubs().createHubV2025R0(new HubCreateRequestV2025R0(hubTitle)); |
| 28 | + String hubId = createdHub.getId(); |
| 29 | + HubDocumentPagesV2025R0 pages = |
| 30 | + client |
| 31 | + .getHubDocument() |
| 32 | + .getHubDocumentPagesV2025R0(new GetHubDocumentPagesV2025R0QueryParams(hubId)); |
| 33 | + assert pages.getEntries().size() > 0; |
| 34 | + assert convertToString(pages.getType()).equals("document_pages"); |
| 35 | + HubDocumentPageV2025R0 firstPage = pages.getEntries().get(0); |
| 36 | + assert convertToString(firstPage.getType()).equals("page"); |
| 37 | + String pageId = firstPage.getId(); |
| 38 | + HubDocumentBlocksV2025R0 blocks = |
| 39 | + client |
| 40 | + .getHubDocument() |
| 41 | + .getHubDocumentBlocksV2025R0(new GetHubDocumentBlocksV2025R0QueryParams(hubId, pageId)); |
| 42 | + assert convertToString(blocks.getType()).equals("document_blocks"); |
| 43 | + assert blocks.getEntries().size() > 0; |
| 44 | + HubDocumentBlockEntryV2025R0 firstBlock = blocks.getEntries().get(0); |
| 45 | + assert convertToString(firstBlock.getType()).equals("item_list"); |
| 46 | + client.getHubs().deleteHubByIdV2025R0(hubId); |
| 47 | + } |
| 48 | +} |
0 commit comments