mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
@@ -0,0 +1,90 @@
|
||||
package org.alfresco.rest.workflow.tasks;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.dataprep.CMISUtil.Priority;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestProcessModel;
|
||||
import org.alfresco.rest.model.RestTaskModel;
|
||||
import org.alfresco.rest.model.RestTaskModelsCollection;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TaskModel;
|
||||
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.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetTaskCoreTests extends RestTest
|
||||
{
|
||||
UserModel userModel, assigneeUser;
|
||||
UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser;
|
||||
SiteModel siteModel;
|
||||
FileModel fileModel;
|
||||
TaskModel taskModel;
|
||||
RestTaskModel restTaskModel, tenantTask;
|
||||
RestTaskModelsCollection taskModels;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
assigneeUser = dataUser.createRandomTestUser();
|
||||
taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
|
||||
public void invalidTaskId() throws Exception
|
||||
{
|
||||
taskModel.setId(RandomStringUtils.randomAlphanumeric(20));
|
||||
restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId()));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 200 is returned.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
|
||||
public void emptyTaskId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel).withWorkflowAPI();
|
||||
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", "");
|
||||
taskModels = restClient.processModels(RestTaskModelsCollection.class, request);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
taskModels.assertThat().entriesListIsNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.")
|
||||
@Test(groups = { TestGroup.NETWORKS })
|
||||
public void tasksInsideNetworkReturned() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
adminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.usingTenant().createTenant(adminTenantUser);
|
||||
|
||||
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant");
|
||||
tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee");
|
||||
|
||||
RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false,
|
||||
Priority.Normal);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess);
|
||||
tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
tenantTask.assertThat().field("assignee").is(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and()
|
||||
.field("processId").is(addedProcess.getId());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
package org.alfresco.rest.workflow.tasks;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
@@ -29,7 +28,7 @@ public class GetTaskSanityTests extends RestTest
|
||||
TaskModel taskModel;
|
||||
RestTaskModel restTaskModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
@@ -39,46 +38,49 @@ public class GetTaskSanityTests extends RestTest
|
||||
taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)")
|
||||
public void adminUserGetsAnyTaskWithSuccess() throws Exception
|
||||
{
|
||||
UserModel adminUser = dataUser.getAdminUser();
|
||||
|
||||
|
||||
restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)")
|
||||
public void assigneeUserGetsItsTaskWithSuccess() throws Exception
|
||||
{
|
||||
restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()).and().field("assignee")
|
||||
.is(assigneeUser.getUsername());
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)")
|
||||
public void starterUserGetsItsTaskWithSuccess() throws Exception
|
||||
{
|
||||
restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)")
|
||||
public void anyUserIsForbiddenToGetOtherTask() throws Exception
|
||||
{
|
||||
UserModel anyUser= dataUser.createRandomTestUser();
|
||||
|
||||
UserModel anyUser = dataUser.createRandomTestUser();
|
||||
|
||||
restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
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 gets its specific task and no other user claimed the task with Rest API and response is successfull (200)")
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)")
|
||||
public void candidateUserGetsItsTasks() throws Exception
|
||||
{
|
||||
UserModel userModel1 = dataUser.createRandomTestUser();
|
||||
@@ -86,16 +88,16 @@ public class GetTaskSanityTests extends RestTest
|
||||
GroupModel group = dataGroup.createRandomGroup();
|
||||
dataGroup.addListOfUsersToGroup(group, userModel1, userModel2);
|
||||
TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group);
|
||||
|
||||
|
||||
restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Bug(id = "MNT-17051")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)")
|
||||
public void involvedUserWithoutClaimTaskGetsTask() throws Exception
|
||||
{
|
||||
UserModel userModel1 = dataUser.createRandomTestUser();
|
||||
@@ -104,10 +106,9 @@ public class GetTaskSanityTests extends RestTest
|
||||
dataGroup.addListOfUsersToGroup(group, userModel1, userModel2);
|
||||
TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group);
|
||||
dataWorkflow.usingUser(userModel1).claimTask(taskModel);
|
||||
|
||||
|
||||
restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId())
|
||||
.and().field("message").is(taskModel.getMessage());
|
||||
restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user