From 2aac94ca91896443544b2fe275432c71bbfec4a1 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Tue, 17 Jan 2017 18:16:13 +0200 Subject: [PATCH 1/3] added full tests for getSiteContainers --- .../sites/GetSiteContainersCoreTests.java | 24 ++-- .../sites/GetSiteContainersFullTests.java | 129 ++++++++++++++++++ 2 files changed, 141 insertions(+), 12 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 298b37c78..70aefbb9b 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -50,7 +50,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 with valid maxItems parameter") public void getContainersWithValidMaxItems() throws Exception { @@ -75,7 +75,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsZero () throws Exception { @@ -87,7 +87,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 400 when invalid maxItems parameter is used") public void getContainersWithMaxItemsCharacter () throws Exception { @@ -99,7 +99,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request returns status code 200 when maxItems parameter starts with multiple zero") public void getContainersWithMaxItemsMultipleZero () throws Exception { @@ -111,7 +111,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when valid skipCount parameter is used") public void getSiteContainersWithValidSkipCount() throws Exception { @@ -137,7 +137,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when invalid skipCount parameter is used") public void getSiteContainersWithSkipCountCharacter() throws Exception { @@ -148,7 +148,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") public void getSiteContainersWithSkipCountMultipleZero() throws Exception { @@ -159,7 +159,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site containers request returns status code 400 when site doesn't exist") public void getSiteContainersWithNonExistentSite() throws Exception { @@ -170,7 +170,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for private site") public void getSiteContainersForPrivateSite() throws Exception { @@ -181,7 +181,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for moderated site") public void getSiteContainersForModeratedSite() throws Exception { @@ -192,7 +192,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for several containers") public void getSiteContainersForSeveralItems() throws Exception { @@ -206,7 +206,7 @@ public class GetSiteContainersCoreTests extends RestTest } @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) - @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify get site containers request returns status 200 for one container") public void getSiteContainersWithOneItem() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java new file mode 100644 index 000000000..57baa59a3 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java @@ -0,0 +1,129 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetSiteContainersFullTests extends RestTest +{ + private SiteModel publicSiteWithContainers; + private ListUserWithRoles publicSiteWithContainersUsers; + RestSiteContainerModelsCollection restSiteContainers; + int totalItems; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + publicSiteWithContainers = dataSite.usingAdmin().createPublicRandomSite(); + + publicSiteWithContainersUsers = dataUser + .addUsersWithRolesToSite(publicSiteWithContainers, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + dataLink.usingAdmin().usingSite(publicSiteWithContainers).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteWithContainers).createRandomDiscussion(); + dataContent.usingAdmin().usingSite(publicSiteWithContainers).createFolder(); + + restSiteContainers = restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers(); + totalItems = restSiteContainers.getPagination().getTotalItems(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request for a container that is not empty returns status code 200") + public void getSiteContainersThatIsNotEmpty() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request returns status code 200 when first container is skipped") + public void getSiteContainersAndSkipFirst() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request and get last container returns status code 200") + public void getLastSiteContainer() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(1) + .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site containers request returns status code 200 when high skipCount parameter is used") + public void getSiteContainersWithHighSkipCount() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withParams("skipCount=999999").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListIsEmpty() + .and().entriesListCountIs(0) + .and().paginationField("skipCount").is("999999"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request for a empty siteId returns status code 404") + public void getSiteContainersForEmptySiteId() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite("").getSiteContainers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request returns status code 200 with valid maxItems parameter") + public void getContainersWithValidMaxItems() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withParams("maxItems=2").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() + .assertThat().entriesListCountIs(2) + .getPagination().assertThat().field("count").is("2") + .and().field("hasMoreItems").is("true") + .and().field("totalItems").is("3") + .and().field("skipCount").is("0") + .and().field("maxItems").is("2"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} From ad45fb6df348fca31e1b8618593c2347fd338041 Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Wed, 18 Jan 2017 10:56:38 +0200 Subject: [PATCH 2/3] added one full test for call using properties parameter --- .../rest/sites/GetSiteContainersFullTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java index 57baa59a3..b4f0210d6 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java @@ -44,6 +44,21 @@ public class GetSiteContainersFullTests extends RestTest totalItems = restSiteContainers.getPagination().getTotalItems(); } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site container request with properties paramater applied returns status code 200") + public void getSiteContainersUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() + .assertThat().entriesListCountIs(3) + .and().entriesListContains("folderId" ,ContainerName.discussions.toString()) + .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId" ,ContainerName.links.toString()) + .and().entriesListDoesNotContain("id"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get site container request for a container that is not empty returns status code 200") From 3716c5abb22302dc7e178680b1c3b8a3b4475e55 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 18 Jan 2017 17:05:01 +0200 Subject: [PATCH 3/3] Minor changes --- .../sites/GetSiteContainersFullTests.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java index b4f0210d6..84d2f1595 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersFullTests.java @@ -46,15 +46,15 @@ public class GetSiteContainersFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request with properties paramater applied returns status code 200") + description= "Verify if get site container request with properties parameter applied returns status code 200") public void getSiteContainersUsingPropertiesParameter() throws Exception { restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingSite(publicSiteWithContainers).usingParams("properties=folderId").getSiteContainers() .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId" ,ContainerName.discussions.toString()) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()) - .and().entriesListContains("folderId" ,ContainerName.links.toString()) + .and().entriesListContains("folderId", ContainerName.discussions.toString()) + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()) + .and().entriesListContains("folderId", ContainerName.links.toString()) .and().entriesListDoesNotContain("id"); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -67,7 +67,7 @@ public class GetSiteContainersFullTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(3) - .and().entriesListContains("folderId" ,ContainerName.documentLibrary.toString()); + .and().entriesListContains("folderId", ContainerName.documentLibrary.toString()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -79,9 +79,9 @@ public class GetSiteContainersFullTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("skipCount=1").withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(2) - .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -93,9 +93,9 @@ public class GetSiteContainersFullTests extends RestTest restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withParams("skipCount=" + String.valueOf(totalItems-1)).withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() .assertThat().entriesListCountIs(1) - .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(0).onModel().getFolderId()) - .and().entriesListDoesNotContain("folderId" , restSiteContainers.getEntries().get(1).onModel().getFolderId()) - .and().entriesListContains("folderId" , restSiteContainers.getEntries().get(2).onModel().getFolderId()); + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(0).onModel().getFolderId()) + .and().entriesListDoesNotContain("folderId", restSiteContainers.getEntries().get(1).onModel().getFolderId()) + .and().entriesListContains("folderId", restSiteContainers.getEntries().get(2).onModel().getFolderId()); restClient.assertStatusCodeIs(HttpStatus.OK); } @@ -114,7 +114,7 @@ public class GetSiteContainersFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request for a empty siteId returns status code 404") + description= "Verify if get site container request for an empty siteId returns status code 404") public void getSiteContainersForEmptySiteId() throws Exception { restClient.authenticateUser(publicSiteWithContainersUsers.getOneUserWithRole(UserRole.SiteManager)) @@ -141,4 +141,4 @@ public class GetSiteContainersFullTests extends RestTest .and().field("maxItems").is("2"); restClient.assertStatusCodeIs(HttpStatus.OK); } -} +} \ No newline at end of file