From 028a424ed5e70ae79574ea986c616a675d039bdf Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 28 Jun 2017 10:53:50 +0100 Subject: [PATCH] REPO-2590: Fix Deleted nodes pagination - add TAS-level test --- .../rest/trashcan/GetDeletedNodesTests.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java diff --git a/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java new file mode 100644 index 000000000..c5fcffc4c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/trashcan/GetDeletedNodesTests.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2005-2017 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.rest.trashcan; + + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +/** + * Tests for /api-explorer/#!/trashcan/listDeletedNodes + * + * @author jcule + * + */ +public class GetDeletedNodesTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel deleteNodesSiteModel; + private FolderModel deleteNodesFolder1, deleteNodesFolder2, deleteNodesFolder3; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + deleteNodesSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + } + + @AfterClass(alwaysRun=true) + public void cleanup() throws Exception + { + dataSite.usingAdmin().deleteSite(deleteNodesSiteModel); + } + + @Test + public void testDeletedNodesBiggerThanMaxCount() throws Exception + { + //get the number of item in the trashcan + RestNodeModelsCollection deletedNodes = restClient.withCoreAPI().usingQueries().findDeletedNodes(); + int count = deletedNodes.getPagination().getCount(); + int totalItems = deletedNodes.getPagination().getTotalItems(); + + //create folders + deleteNodesFolder1 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder2 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + deleteNodesFolder3 = dataContent.usingUser(adminUserModel).usingSite(deleteNodesSiteModel).createFolder(); + + //delete folders + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder1).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder2).deleteContent(); + dataContent.usingUser(adminUserModel).usingResource(deleteNodesFolder3).deleteContent(); + + int maxItems = count + 1; + RestNodeModelsCollection deletedNodesMaxItem = restClient.withCoreAPI().usingQueries().usingParams(String.format("maxItems=%s", maxItems)).findDeletedNodes(); + + String countMaxItem = Integer.toString(maxItems); + String totalItemsMaxItem = Integer.toString(totalItems + 3); + String hasMoreItemsMaxItem = Boolean.toString(deletedNodesMaxItem.getPagination().isHasMoreItems()); + String skipCount = Integer.toString(deletedNodesMaxItem.getPagination().getSkipCount()); + + restClient.assertStatusCodeIs(HttpStatus.OK); + deletedNodesMaxItem.getPagination().assertThat().field("totalItems").is(totalItemsMaxItem).and().field("count").is(countMaxItem); + deletedNodesMaxItem.getPagination().assertThat().field("hasMoreItems").is(hasMoreItemsMaxItem).and().field("skipCount").is(skipCount); + + } + + +}