added full tests for getProcess

This commit is contained in:
Cristina Axinte
2017-02-01 17:21:34 +02:00
parent 83f2cdc814
commit 02d87da718
2 changed files with 108 additions and 4 deletions
@@ -28,7 +28,7 @@ public class GetProcessCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify that using invalid process ID returns status code 404")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE})
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE})
public void invalidProcessIdTest() throws Exception
{
RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High);
@@ -41,7 +41,7 @@ public class GetProcessCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION,
description = "Verify that tenant user cannot get process from another network")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS })
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS })
@Bug(id = "MNT-17238")
public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception
{
@@ -62,7 +62,7 @@ public class GetProcessCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify that tenant user can get process from the same network")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS })
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS })
public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception
{
UserModel adminTenantUser1 = UserModel.getAdminTenantUser();
@@ -79,7 +79,7 @@ public class GetProcessCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION,
description = "Verify that non network user cannot get process from a network")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS })
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS })
@Bug(id = "MNT-17238")
public void nonNetworkUserCannotAccessNetworkprocess() throws Exception
{
@@ -0,0 +1,104 @@
package org.alfresco.rest.workflow.processes;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestProcessModel;
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.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
*
* @author Cristina Axinte
*
*/
public class GetProcessFullTests extends RestTest
{
private UserModel userWhoStartsProcess, assignee;
private RestProcessModel addedProcess, process;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
userWhoStartsProcess = dataUser.createRandomTestUser();
assignee = dataUser.createRandomTestUser();
addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify that admin user can get process started by a network user")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS })
public void adminUserCanGetProcessFromANetwork() throws Exception
{
UserModel adminTenantUser1 = UserModel.getAdminTenantUser();
restClient.authenticateUser(dataUser.getAdminUser()).usingTenant().createTenant(adminTenantUser1);
UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("utenant1");
RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiReview", adminTenantUser1, false, CMISUtil.Priority.High);
restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingProcess(networkProcess1).getProcess();
restClient.assertStatusCodeIs(HttpStatus.OK);
networkProcess1.assertThat().field("processDefinitionId").contains(String.format("@%s%s", tenantUser1.getDomain().toLowerCase(), "@activitiReview:1"))
.and().field("startUserId").is(tenantUser1.getEmailAddress().toLowerCase())
.and().field("startActivityId").is("start")
.and().field("startedAt").isNotEmpty()
.and().field("id").is(networkProcess1.getId())
.and().field("completed").is(false)
.and().field("processDefinitionKey").is("activitiReview");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user is able to get the process with properties parameter applied using REST API")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getProcessWithPropertiesParameter() throws Exception
{
process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingParams("properties=startUserId,id").usingProcess(addedProcess).getProcess();
restClient.assertStatusCodeIs(HttpStatus.OK);
process.assertThat().fieldsCount().is(2)
.and().field("startUserId").is(addedProcess.getStartUserId())
.and().field("id").is(addedProcess.getId())
.and().field("processDefinitionKey").isNull();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user is able to get a process that was deleted, but it has 'deleted through REST API call' deleteReason")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getDeletedProcess() throws Exception
{
addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High);
process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess();
restClient.assertStatusCodeIs(HttpStatus.OK);
process.assertThat()
.field("processDefinitionId").is("activitiAdhoc:1:4")
.and().field("startUserId").is(addedProcess.getStartUserId())
.and().field("startActivityId").is("start")
.and().field("startedAt").isNotEmpty()
.and().field("id").is(addedProcess.getId())
.and().field("completed").is(false)
.and().field("processDefinitionKey").is("activitiAdhoc");
restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).deleteProcess();
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
process = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(addedProcess).getProcess();
restClient.assertStatusCodeIs(HttpStatus.OK);
process.assertThat()
.field("processDefinitionId").is("activitiAdhoc:1:4")
.and().field("durationInMs").isNotNull()
.and().field("startUserId").is(addedProcess.getStartUserId())
.and().field("startActivityId").is("start")
.and().field("endedAt").isNotEmpty()
.and().field("startedAt").isNotEmpty()
.and().field("id").is(addedProcess.getId())
.and().field("completed").is(true)
.and().field("deleteReason").is("deleted through REST API call")
.and().field("processDefinitionKey").is("activitiAdhoc");
restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", process.getId());
}
}