From 9aeafea91e200b9f4f6b4b9a75ffa01139b7a3b8 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Tue, 29 Nov 2016 11:47:53 +0200 Subject: [PATCH] CORE-REST API: getTags (get /tags) --- .../alfresco/rest/tags/GetTagsCoreTests.java | 89 +++++++++++++++++++ .../rest/tags/GetTagsSanityTests.java | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java new file mode 100644 index 000000000..54a141fdd --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsCoreTests.java @@ -0,0 +1,89 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class GetTagsCoreTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel siteModel; + + private String tagValue; + private String tagValue2; + private FileModel document; + private RestTagModelsCollection returnedCollection; + private FolderModel folder; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + tagValue = RandomData.getRandomName("tag"); + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(document).addTags(tagValue); + restClient.withCoreAPI().usingResource(folder).addTags(tagValue2); + + Utility.waitToLoopTime(60); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if maxItems is invalid status code returned is 400") + public void maxItemsInvalidValueTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if skipCount is invalid status code returned is 400") + public void skipCountInvalidValueTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that file tag is retrieved") + public void fileTagIsRetrieved() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that folder tag is retrieved") + public void folderTagIsRetrieved() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel); + returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index d9f05070e..e0c9fd788 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -102,7 +102,7 @@ public class GetTagsSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role") @Bug(id = "MNT-16904") - public void getTagsWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); userModel = dataUser.createRandomTestUser();