mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
updated test after review: AddTaskVariablesCoreTests
This commit is contained in:
@@ -3,6 +3,7 @@ package org.alfresco.rest.workflow.tasks;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestVariableModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
@@ -20,38 +21,33 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
|
||||
public class AddTaskVariablesCoreTests extends RestTest
|
||||
{
|
||||
private UserModel userModel, userWhoStartsTask;
|
||||
private UserModel userWhoStartsTask, adminUser;
|
||||
private SiteModel siteModel;
|
||||
private FileModel fileModel;
|
||||
private UserModel assigneeUser;
|
||||
private TaskModel taskModel;
|
||||
private RestVariableModel restVariablemodel;
|
||||
|
||||
private UserModel adminUser;
|
||||
private String taskId;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
|
||||
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
adminUser = dataUser.getAdminUser();
|
||||
userWhoStartsTask = dataUser.createRandomTestUser();
|
||||
assigneeUser = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
|
||||
|
||||
adminUser = dataUser.getAdminUser();
|
||||
taskId = taskModel.getId();
|
||||
restClient.authenticateUser(adminUser);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided")
|
||||
public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char");
|
||||
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'.");
|
||||
|
||||
@@ -60,10 +56,8 @@ public class AddTaskVariablesCoreTests extends RestTest
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided")
|
||||
public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", "");
|
||||
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsSummary("Variable scope is required and can only be 'local' or 'global'.");
|
||||
@@ -73,8 +67,6 @@ public class AddTaskVariablesCoreTests extends RestTest
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided")
|
||||
public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"missingVariableScope\",\"value\": \"test\",\"type\": \"d:text\"}",
|
||||
"tasks/{taskId}/variables", taskId);
|
||||
restClient.processModel(RestVariableModel.class, request);
|
||||
@@ -87,8 +79,6 @@ public class AddTaskVariablesCoreTests extends RestTest
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided")
|
||||
public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"value\": \"missingVariableName\",\"type\": \"d:text\"}",
|
||||
"tasks/{taskId}/variables", taskId);
|
||||
restClient.processModel(RestVariableModel.class, request);
|
||||
@@ -100,11 +90,9 @@ public class AddTaskVariablesCoreTests extends RestTest
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided")
|
||||
public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char");
|
||||
taskModel.setId(taskId);
|
||||
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'.");
|
||||
|
||||
@@ -114,22 +102,20 @@ public class AddTaskVariablesCoreTests extends RestTest
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided")
|
||||
public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text");
|
||||
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
taskModel.setId(taskId);
|
||||
restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided")
|
||||
public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text");
|
||||
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
taskModel.setId(taskId);
|
||||
restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'.");
|
||||
|
||||
@@ -138,22 +124,18 @@ public class AddTaskVariablesCoreTests extends RestTest
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided")
|
||||
public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text");
|
||||
taskModel.setId(taskModel.getId() + "TEST");
|
||||
restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary("The entity with id: " + taskModel.getId() + " was not found");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId()));
|
||||
|
||||
}
|
||||
|
||||
@Bug(id = "ACE-5673")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided")
|
||||
public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
|
||||
RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int");
|
||||
variableModel.setValue("invalidValue");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user