test added: AddProcessVariableCoreTests

This commit is contained in:
mionescu
2016-12-08 16:11:01 +02:00
parent 37f0b82b10
commit b2727de5af
@@ -0,0 +1,159 @@
package org.alfresco.rest.workflow.processes;
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.RestProcessModel;
import org.alfresco.rest.model.RestProcessVariableModel;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE })
public class AddProcessVariableCoreTests extends RestTest
{
private FileModel document;
private SiteModel siteModel;
private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, adminTenantUser2, tenantUserAssignee;
private RestProcessModel processModel;
private RestProcessVariableModel variableModel, processVariable;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
userWhoStartsProcess = dataUser.createRandomTestUser();
assignee = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite();
document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee);
anotherUser = dataUser.createRandomTestUser();
adminUser = dataUser.getAdminUser();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by the user who started the process.")
public void addProcessVariableByUserThatStartedTheProcess() throws Exception
{
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal);
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is(variableModel.getName()).and().field("type").is(variableModel.getType()).and().field("value")
.is(variableModel.getValue());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by a random user.")
public void addProcessVariableByAnyUser() throws Exception
{
processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal);
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
processVariable.assertThat().field("name").is(variableModel.getName()).and().field("type").is(variableModel.getType()).and().field("value")
.is(variableModel.getValue());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, description = "Add process variable using by admin in other network.")
public void addProcessVariableByAdminInOtherNetwork() throws Exception
{
adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser);
tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee");
adminTenantUser2 = UserModel.getAdminTenantUser();
restClient.usingTenant().createTenant(adminTenantUser2);
processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal);
restClient.authenticateUser(adminTenantUser2);
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Process is running in another tenant");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type is provided")
public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:textarea'.");
}
@Bug(id = "ACE-5674")
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid type prefix is provided")
public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception
{
variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid value is provided")
public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception
{
RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int");
variableModel.setValue("invalidValue");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\"");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case missing required variable body (name) is provided")
public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName());
restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required.");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided")
public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}",
"processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName());
restClient.processModel(RestProcessVariableModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\"");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case empty name is provided")
public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal);
RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
variableModel.setName("");
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary("PUT is executed against the instance URL");
}
}