mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'TAS-1964' into '5.1.N-newDSL'
Tas 1964 Refactor Test: UploadTaskSanityTests.java See merge request !185
This commit is contained in:
@@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.tasks;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.requests.RestTasksApi;
|
||||
import org.alfresco.rest.model.RestTaskModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.GroupModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
@@ -11,7 +11,6 @@ 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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -19,15 +18,13 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
|
||||
public class UploadTaskSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestTasksApi tasksApi;
|
||||
|
||||
UserModel userModel;
|
||||
SiteModel siteModel;
|
||||
UserModel candidateUser;
|
||||
FileModel fileModel;
|
||||
UserModel assigneeUser;
|
||||
TaskModel taskModel;
|
||||
RestTaskModel restTaskModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
@@ -37,37 +34,33 @@ public class UploadTaskSanityTests extends RestTest
|
||||
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
assigneeUser = dataUser.createRandomTestUser();
|
||||
taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
|
||||
|
||||
tasksApi.useRestClient(restClient);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)")
|
||||
public void adminUserUpdatesAnyTaskWithSuccess() throws Exception
|
||||
{
|
||||
UserModel adminUser = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUser);
|
||||
tasksApi.updateTask(taskModel)
|
||||
.assertThat().field("id").is(taskModel.getId())
|
||||
|
||||
restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)")
|
||||
public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(assigneeUser);
|
||||
tasksApi.updateTask(taskModel)
|
||||
.assertThat().field("id").is(taskModel.getId())
|
||||
restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)")
|
||||
public void starterUserUpdatesItsTaskWithSuccess() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel);
|
||||
tasksApi.updateTask(taskModel);
|
||||
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)")
|
||||
@@ -75,9 +68,8 @@ public class UploadTaskSanityTests extends RestTest
|
||||
{
|
||||
UserModel anyUser= dataUser.createRandomTestUser();
|
||||
|
||||
restClient.authenticateUser(anyUser);
|
||||
tasksApi.updateTask(taskModel);
|
||||
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied");
|
||||
restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)")
|
||||
@@ -89,10 +81,9 @@ public class UploadTaskSanityTests extends RestTest
|
||||
dataGroup.addListOfUsersToGroup(group, userModel1, userModel2);
|
||||
TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group);
|
||||
|
||||
restClient.authenticateUser(userModel1);
|
||||
tasksApi.updateTask(taskModel)
|
||||
.assertThat().field("id").is(taskModel.getId())
|
||||
restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user