added full tests for getProcesses and refactoring

This commit is contained in:
Cristina Axinte
2017-01-31 15:47:56 +02:00
parent a5e2bcdb33
commit d3d3dca04e
4 changed files with 169 additions and 4 deletions
@@ -50,7 +50,7 @@ public class GetSiteMembersFullTests extends RestTest
firstSiteMember = siteMembers.getEntries().get(0).onModel();
secondSiteMember = siteMembers.getEntries().get(1).onModel();
thirdSiteMember = siteMembers.getEntries().get(2).onModel();
fourthSiteMember = siteMembers.getEntries().get(2).onModel();
fourthSiteMember = siteMembers.getEntries().get(3).onModel();
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@@ -62,7 +62,7 @@ public class GetProcessDefinitionsCoreTests extends RestTest
.getAllProcessDefinitions()
.assertThat().entriesListIsEmpty();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_ORDERBY, "test"));
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "deploymentId, name, id, category, version, key"));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION,
@@ -76,6 +76,6 @@ public class GetProcessDefinitionsCoreTests extends RestTest
.getAllProcessDefinitions()
.assertThat().entriesListIsEmpty();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_WHERE, "test"));
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "test"));
}
}
@@ -13,7 +13,6 @@ 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.apache.commons.lang.RandomStringUtils;
@@ -0,0 +1,166 @@
package org.alfresco.rest.workflow.processes;
import java.util.List;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.dataprep.CMISUtil.Priority;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestProcessModel;
import org.alfresco.rest.model.RestProcessModelsCollection;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.ProcessModel;
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.report.Bug;
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 GetProcessesFullTests extends RestTest
{
private FileModel document;
private SiteModel siteModel;
private UserModel adminUser, userWhoStartsTask, assignee;
private TaskModel task1, task2;
private ProcessModel process3;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
userWhoStartsTask = dataUser.createRandomTestUser();
assignee = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite();
document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
task1 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee);
task2 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(adminUser);
process3 = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify any user cannot get processes from same network")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS })
public void getProcessFromSameNetworkUsingAnyUser() throws Exception
{
UserModel adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser);
UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
UserModel tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee");
restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal);
UserModel otherTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("otherTenant");
RestProcessModelsCollection tenantProcesses = restClient.authenticateUser(otherTenantUser).withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.OK);
tenantProcesses.assertThat().entriesListIsEmpty().and().paginationField("count").is("0");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user gets processes when skipCount parameter is applied")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getProcessesWithSkipCountParameter() throws Exception
{
RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.OK);
processes.assertThat().paginationField("count").is("3");
RestProcessModel process1 = processes.getEntries().get(0).onModel();
RestProcessModel process2 = processes.getEntries().get(1).onModel();
RestProcessModel process3 = processes.getEntries().get(2).onModel();
processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("skipCount=2").getProcesses();
restClient.assertStatusCodeIs(HttpStatus.OK);
processes.assertThat().paginationField("count").is("1");
processes.assertThat().paginationField("skipCount").is("2");
processes.assertThat().entriesListDoesNotContain("id", process1.getId());
processes.assertThat().entriesListDoesNotContain("id", process2.getId());
processes.getEntries().get(0).onModel().assertThat().field("id").is(process3.getId());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user gets processes when maxItems parameter is applied")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getProcessesWithMaxItemsParameter() throws Exception
{
RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.OK);
processes.assertThat().paginationField("count").is("3");
RestProcessModel process1 = processes.getEntries().get(0).onModel();
RestProcessModel process2 = processes.getEntries().get(1).onModel();
RestProcessModel process3 = processes.getEntries().get(2).onModel();
processes = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingParams("maxItems=2").getProcesses();
restClient.assertStatusCodeIs(HttpStatus.OK);
processes.assertThat().paginationField("count").is("2");
processes.assertThat().paginationField("maxItems").is("2");
processes.assertThat().entriesListDoesNotContain("id", process3.getId());
processes.getEntries().get(0).onModel().assertThat().field("id").is(process1.getId());
processes.getEntries().get(1).onModel().assertThat().field("id").is(process2.getId());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user gets processes when properties parameter is applied")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getProcessesWithPropertiesParameter() throws Exception
{
RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id")
.withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.OK);
processes.assertThat().entriesListIsNotEmpty();
List<RestProcessModel> processesList = processes.getEntries();
processesList.get(0).onModel().assertThat().fieldsCount().is(1).and().field("id").is(process3.getId());
processesList.get(1).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task2.getNodeRef());
processesList.get(2).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task1.getNodeRef());
}
@Bug(id = "REPO-1958")
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot get processes when using an invalid orderBy parameter")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getProcessesWithInvalidOrderByParameter() throws Exception
{
restClient.authenticateUser(userWhoStartsTask).withParams("orderBy=test")
.withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsErrorKey(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey"))
.containsSummary(String.format(RestErrorModel.INVALID_ORDERBY, "test", "processDefinitionId, startUserId, startActivityId,startedAt, id, completed, processDefinitionKey"))
.stackTraceIs(RestErrorModel.STACKTRACE)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot get processes when using an invalid parameter in where clause")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getProcessesWithInvalidWhereParameter() throws Exception
{
restClient.authenticateUser(userWhoStartsTask).where("startUserIdd='" + userWhoStartsTask.getUsername() + "'")
.withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsErrorKey(RestErrorModel.INVALID_PROPERTY_ERRORKEY)
.containsSummary(String.format(RestErrorModel.PROPERTY_IS_NOT_SUPPORTED_EQUALS, "startUserIdd", userWhoStartsTask.getUsername()))
.stackTraceIs(RestErrorModel.STACKTRACE)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot get processes when using an invalid where clause expression")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void getProcessesWithInvalidWhereClauseExpression() throws Exception
{
restClient.authenticateUser(userWhoStartsTask).where("startUserId AND '" + userWhoStartsTask.getUsername() + "'")
.withWorkflowAPI().getProcesses();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY)
.containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(startUserId AND '" + userWhoStartsTask.getUsername() + "')"))
.stackTraceIs(RestErrorModel.STACKTRACE)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
}
}