made the changes according to review comments

This commit is contained in:
Andrei Rusu
2016-12-09 11:34:04 +02:00
parent e5587b4398
commit e140de25ea
@@ -3,9 +3,11 @@ package org.alfresco.rest.workflow.tasks;
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.RestErrorModel;
import org.alfresco.rest.model.RestProcessModel;
import org.alfresco.rest.model.RestTaskModel;
import org.alfresco.utility.model.RestErrorModel;
import org.alfresco.rest.model.RestTaskModelsCollection;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TaskModel;
@@ -14,13 +16,14 @@ import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetTaskCoreTests extends RestTest
{
UserModel userModel, candidateUser, assigneeUser;
UserModel userModel, assigneeUser;
UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser;
SiteModel siteModel;
FileModel fileModel;
@@ -38,17 +41,6 @@ public class GetTaskCoreTests extends RestTest
taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify valid request for auth user which is asignee.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
public void validRequestWithAuthUser() throws Exception
{
restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask();
restClient.assertStatusCodeIs(HttpStatus.OK);
restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("message").is(taskModel.getMessage()).and().field("assignee")
.is(assigneeUser.getUsername());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using invalid taskId status code 404 is returned.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
@@ -60,6 +52,18 @@ public class GetTaskCoreTests extends RestTest
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId()));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify if using empty taskId status code 404 is returned.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
public void emptyTaskId() throws Exception
{
restClient.authenticateUser(userModel).withCoreAPI();
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}?{parameters}", "", restClient.getParameters());
restClient.processModels(RestTaskModelsCollection.class, request);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
.containsSummary(String.format(RestErrorModel.UNABLE_TO_LOCATE, taskModel.getId()));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in a network only tasks inside network are returned.")
@Test(groups = { TestGroup.NETWORKS })
@@ -75,10 +79,11 @@ public class GetTaskCoreTests extends RestTest
RestProcessModel addedProcess = restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false,
Priority.Normal);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess);
tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().usingTask(taskModel).getTask();
restClient.assertStatusCodeIs(HttpStatus.OK);
tenantTask.assertThat().field("assignee").is(tenantUserAssignee.getUsername()).and().field("processId").is(addedProcess.getId());
tenantTask.assertThat().field("assignee").is(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and()
.field("processId").is(addedProcess.getId());
}
}