Merge branch 'TAS-1960' into '5.1.N-newDSL'

Tas 1960

Refactor Test: GetTaskVariablesSanityTests.java

See merge request !196
This commit is contained in:
Paul Brodner
2016-11-17 11:43:34 +00:00
@@ -2,7 +2,7 @@ package org.alfresco.rest.workflow.tasks;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.requests.RestTasksApi;
import org.alfresco.rest.model.RestVariableModelsCollection;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TaskModel;
@@ -10,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;
@@ -21,14 +20,12 @@ import org.testng.annotations.Test;
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY })
public class GetTaskVariablesSanityTests extends RestTest
{
@Autowired
RestTasksApi tasksApi;
private UserModel userModel, userWhoStartsTask, assignee;
private SiteModel siteModel;
private FileModel fileModel;
private TaskModel taskModel;
private RestVariableModelsCollection variableModels;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
@@ -38,8 +35,6 @@ public class GetTaskVariablesSanityTests extends RestTest
userWhoStartsTask = dataUser.createRandomTestUser();
assignee = dataUser.createRandomTestUser();
taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee);
tasksApi.useRestClient(restClient);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
@@ -47,8 +42,9 @@ public class GetTaskVariablesSanityTests extends RestTest
public void getTaskVariablesByUserWhoStartedProcess() throws Exception
{
restClient.authenticateUser(userWhoStartsTask);
tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty();
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables();
restClient.assertStatusCodeIs(HttpStatus.OK);
variableModels.assertThat().entriesListIsNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
@@ -56,8 +52,9 @@ public class GetTaskVariablesSanityTests extends RestTest
public void getTaskVariablesByUserInvolvedInProcess() throws Exception
{
restClient.authenticateUser(assignee);
tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty();
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables();
restClient.assertStatusCodeIs(HttpStatus.OK);
variableModels.assertThat().entriesListIsNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
@@ -67,18 +64,19 @@ public class GetTaskVariablesSanityTests extends RestTest
UserModel randomUser = dataUser.createRandomTestUser();
restClient.authenticateUser(randomUser);
tasksApi.getTaskVariables(taskModel);
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied");
restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables();
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY,
description = "Verify that admin gets task variables")
description = "Verify that admin is able to task variables")
public void getTaskVariablesUsingAdmin() throws Exception
{
UserModel adminUser = dataUser.getAdminUser();
restClient.authenticateUser(adminUser);
tasksApi.getTaskVariables(taskModel).assertThat().entriesListIsNotEmpty();
tasksApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables();
restClient.assertStatusCodeIs(HttpStatus.OK);
variableModels.assertThat().entriesListIsNotEmpty();
}
}
}