From 2a13d867d277089d95483f35c2d9a80dbd149883 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 29 Sep 2016 10:00:14 +0300 Subject: [PATCH] TAS-959 deleteComment with Manager --- .../comments/DeleteCommentsSanityTests.java | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index 299970f21..07c2e5aea 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -1,9 +1,13 @@ package org.alfresco.rest.comments; +import java.util.Arrays; +import java.util.HashMap; + import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.requests.RestCommentsApi; +import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.SiteModel; @@ -13,6 +17,7 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(groups = { "rest-api", "comments", "sanity" }) @@ -21,16 +26,17 @@ public class DeleteCommentsSanityTests extends RestTest @Autowired RestCommentsApi commentsAPI; - + @Autowired DataUser dataUser; - + private UserModel adminUserModel; - + private FileModel document; private SiteModel siteModel; private String commentId; - + private HashMap usersWithRoles; + @BeforeClass public void initTest() throws Exception { @@ -39,15 +45,34 @@ public class DeleteCommentsSanityTests extends RestTest siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); commentsAPI.useRestClient(restClient); document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + } + + @BeforeMethod + public void initMethod() throws Exception + { + restClient.authenticateUser(adminUserModel); + commentsAPI.useRestClient(restClient); commentId = commentsAPI.addComment(document.getNodeRef(), "This is a new comment").getId(); } - - @TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY, - description= "Verify Admin user gets comments with Rest API and status code is 200") - public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception + + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Admin user delete comments with Rest API and status code is 204") + public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception { commentsAPI.deleteComment(document.getNodeRef(), commentId); commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); } + @TestRail(section = { "rest-api", + "comments" }, executionType = ExecutionType.SANITY, description = "Verify Manager user delete comments created by admin user with Rest API and status code is 204") + public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + commentsAPI.deleteComment(document.getNodeRef(), commentId); + commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT.toString()); + } + }