Refactor Test: AddTaskVariablesSanityTests.java

This commit is contained in:
Valentin Popa
2016-11-17 11:11:24 +02:00
parent 11a8ffaf0c
commit 52eb4a7e68
@@ -3,7 +3,6 @@ package org.alfresco.rest.workflow.tasks;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestVariableModel;
import org.alfresco.rest.requests.RestTasksApi;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TaskModel;
@@ -11,7 +10,6 @@ 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.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -22,14 +20,12 @@ import org.testng.annotations.Test;
@Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
public class AddTaskVariablesSanityTests extends RestTest
{
@Autowired
RestTasksApi tasksApi;
private UserModel userModel, userWhoStartsTask;
private SiteModel siteModel;
private FileModel fileModel;
private UserModel assigneeUser;
private TaskModel taskModel;
private RestVariableModel restVariablemodel;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
@@ -40,8 +36,6 @@ public class AddTaskVariablesSanityTests extends RestTest
userWhoStartsTask = dataUser.createRandomTestUser();
assigneeUser = dataUser.createRandomTestUser();
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
tasksApi.useRestClient(restClient);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
@@ -51,13 +45,14 @@ public class AddTaskVariablesSanityTests extends RestTest
UserModel adminUser = dataUser.getAdminUser();
restClient.authenticateUser(adminUser);
RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text");
tasksApi.addTaskVariable(taskModel, variableModel)
.assertThat()
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restVariablemodel.assertThat()
.field("scope").is(variableModel.getScope())
.and().field("name").is(variableModel.getName())
.and().field("value").is(variableModel.getValue())
.and().field("type").is(variableModel.getType());
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
@@ -66,13 +61,15 @@ public class AddTaskVariablesSanityTests extends RestTest
{
restClient.authenticateUser(assigneeUser);
RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text");
tasksApi.addTaskVariable(taskModel, variableModel)
.assertThat().field("scope").is(variableModel.getScope())
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restVariablemodel.assertThat().field("scope").is(variableModel.getScope())
.and().field("name").is(variableModel.getName())
.and().field("value").is(variableModel.getValue())
.and().field("type").is(variableModel.getType());
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
tasksApi.getTaskVariables(taskModel).assertThat().entriesListContains("name", variableModel.getName());
restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName());
}
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
@@ -81,12 +78,13 @@ public class AddTaskVariablesSanityTests extends RestTest
{
restClient.authenticateUser(userWhoStartsTask);
RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text");
tasksApi.addTaskVariable(taskModel, variableModel)
.assertThat().field("scope").is(variableModel.getScope())
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restVariablemodel.assertThat().field("scope").is(variableModel.getScope())
.and().field("name").is(variableModel.getName())
.and().field("value").is(variableModel.getValue())
.and().field("type").is(variableModel.getType());
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
}
@TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
@@ -96,7 +94,8 @@ public class AddTaskVariablesSanityTests extends RestTest
userModel = dataUser.createRandomTestUser();
restClient.authenticateUser(userModel);
RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text");
tasksApi.addTaskVariable(taskModel, variableModel);
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied");
restVariablemodel = restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied");
}
}