diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 2477c46df..ae2d5425b 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -59,7 +59,7 @@ public class FunctionalCasesTests extends RestTest * 3. Update it's role to Contributor * 4. Update it's role to Consumer */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to update manager with different roles and gets status code CREATED (201)") public void managerIsAbleToUpdateManagerWithDifferentRoles() throws Exception @@ -97,7 +97,7 @@ public class FunctionalCasesTests extends RestTest * 3. Update it's role to Collaborator * 4. Update it's role to Manager */ - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to update consumer with different roles and gets status code CREATED (201)") public void managerIsAbleToUpdateConsumerWithDifferentRoles() throws Exception @@ -137,7 +137,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Approve request, add site to favorites, then delete it from favorites") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void approveRequestAddAndDeleteSiteFromFavorites() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -170,7 +170,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Reject request, add moderated site to favorites, create request again and approve it") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void rejectRequestAddModeratedSiteToFavorites() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -205,7 +205,7 @@ public class FunctionalCasesTests extends RestTest * 1. Add file * 2. Check file is included in person activities list */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Add a file and check that activity is included in person activities") public void addFileThenGetPersonActivities() throws Exception @@ -223,7 +223,7 @@ public class FunctionalCasesTests extends RestTest * 1. Add a comment to a file * 2. Check that comment is included in person activities list */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Add a comment to a file and check that activity is included in person activities") public void addCommentThenGetPersonActivities() throws Exception @@ -242,7 +242,7 @@ public class FunctionalCasesTests extends RestTest * 1. Add file then delete it * 2. Check action is included in person activities list */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Add a file, delete it and check that activity is included in person activities") public void addFileDeleteItThenGetPersonActivities() throws Exception @@ -263,7 +263,7 @@ public class FunctionalCasesTests extends RestTest * 4. Get again comment details * 5. Delete comment */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.") @@ -297,7 +297,7 @@ public class FunctionalCasesTests extends RestTest * 2. Delete comment * 3. Post the same comment again */ - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Add a comment to a file, delete it, then added the same comment again.") @@ -334,7 +334,7 @@ public class FunctionalCasesTests extends RestTest * @throws Exception */ - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Create an user, join the user to a site and check that activity is included in person activities") public void joinUserToSiteThenGetPersonActivities() throws Exception @@ -357,7 +357,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -384,7 +384,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -415,7 +415,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception { file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -442,7 +442,7 @@ public class FunctionalCasesTests extends RestTest */ @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception { UserModel newUser = dataUser.createRandomTestUser(); @@ -474,7 +474,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Add one file to favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void commentAFavoriteFile() throws Exception { file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -496,7 +496,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Remove one file from favorites then add a comment to this file") - @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION }) public void commentFileRemovedFromFavorites() throws Exception { file = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); @@ -525,7 +525,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Check favorite sites after a favorite site visibility is changed") - @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.REGRESSION }) public void changeFavoriteSiteVisibilityThenCheckFavorites() throws Exception { SiteModel favoriteSite = dataSite.usingUser(manager).createPublicRandomSite(); @@ -577,7 +577,7 @@ public class FunctionalCasesTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Check that a user who joins a moderated site as manager is able to comment, rate, tag an existing file from the site, add site to favorites, add and remove site members.") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) public void checkNewManagerActions() throws Exception { UserModel newMember = dataUser.createRandomTestUser(); @@ -655,7 +655,7 @@ public class FunctionalCasesTests extends RestTest * @throws Exception */ @Bug(id="REPO-1830") - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful") public void userGetsItsPeopleActivities() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java deleted file mode 100644 index dd2b8906e..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskCoreTests.java +++ /dev/null @@ -1,90 +0,0 @@ -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.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -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.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, assigneeUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestTaskModel restTaskModel, tenantTask; - RestTaskModelsCollection taskModels; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @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 }) - public void invalidTaskId() throws Exception - { - taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .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 200 is returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void emptyTaskId() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - taskModels = restClient.processModels(RestTaskModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @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,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void tasksInsideNetworkReturned() throws Exception - { - restClient.authenticateUser(adminUser); - - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); - - 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(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and() - .field("processId").is(addedProcess.getId()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java deleted file mode 100644 index 366a60ead..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelCoreTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.utility.model.FileModel; -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.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 bogdan.bocancea - * - */ -public class GetTaskFormModelCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestFormModelsCollection returnedCollection; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void nonInvolvedUserCannotGetTaskFormModels() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - UserModel nonInvolvedUser = dataUser.createRandomTestUser(); - restClient.authenticateUser(nonInvolvedUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskFormModelsInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId("0000"); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task cannot get task form models with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskFormModelsEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(userModel); - taskModel.setId(""); - restClient.authenticateUser(userModel); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify user involved in task can get completed task form models") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskFormModelsForCompletedTask() throws Exception - { - UserModel assignedUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); - dataWorkflow.usingUser(assignedUser).taskDone(taskModel); - dataWorkflow.usingUser(userModel).taskDone(taskModel); - restClient.authenticateUser(userModel); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java deleted file mode 100644 index 36a98a800..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestFormModelsCollection; -import org.alfresco.utility.model.FileModel; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 10/20/2016. - */ - -public class GetTaskFormModelSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - FileModel fileModel; - TaskModel taskModel; - RestFormModelsCollection returnedCollection; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") - public void adminGetsTaskFormModels() throws Exception - { - returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - - String[] qualifiedNames = { - "{http://www.alfresco.org/model/bpm/1.0}percentComplete", - "{http://www.alfresco.org/model/bpm/1.0}context", - "{http://www.alfresco.org/model/bpm/1.0}completedItems", - "{http://www.alfresco.org/model/content/1.0}name", - "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}reassignable", - "{http://www.alfresco.org/model/content/1.0}owner", - "{http://www.alfresco.org/model/bpm/1.0}outcome", - "{http://www.alfresco.org/model/bpm/1.0}taskId", - "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", - "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; - - for(String formQualifiedName : qualifiedNames) - { - returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); - } - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") - public void involvedUserGetsTaskFormModels() throws Exception - { - returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); - restClient.assertStatusCodeIs(HttpStatus.OK); - returnedCollection.assertThat().entriesListIsNotEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java similarity index 56% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java index d9b501d60..b7359652b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelTests.java @@ -14,7 +14,7 @@ import org.testng.annotations.Test; /** * Created by Claudia Agache on 2/3/2017. */ -public class GetTaskFormModelFullTests extends RestTest +public class GetTaskFormModelTests extends RestTest { UserModel userModel, adminUser; SiteModel siteModel; @@ -29,14 +29,120 @@ public class GetTaskFormModelFullTests extends RestTest userModel = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify admin user gets all task form models with Rest API and response is successful (200)") + public void adminGetsTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + + String[] qualifiedNames = { + "{http://www.alfresco.org/model/bpm/1.0}percentComplete", + "{http://www.alfresco.org/model/bpm/1.0}context", + "{http://www.alfresco.org/model/bpm/1.0}completedItems", + "{http://www.alfresco.org/model/content/1.0}name", + "{http://www.alfresco.org/model/bpm/1.0}packageActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}reassignable", + "{http://www.alfresco.org/model/content/1.0}owner", + "{http://www.alfresco.org/model/bpm/1.0}outcome", + "{http://www.alfresco.org/model/bpm/1.0}taskId", + "{http://www.alfresco.org/model/bpm/1.0}packageItemActionGroup", + "{http://www.alfresco.org/model/bpm/1.0}completionDate"}; + + for(String formQualifiedName : qualifiedNames) + { + returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); + } + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.SANITY, description = "Verify user involved in task gets all the task form models with Rest API and response is successful (200)") + public void involvedUserGetsTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify that non involved user in task cannot get form models with Rest API and response is FORBIDDEN (403)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void nonInvolvedUserCannotGetTaskFormModels() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + UserModel nonInvolvedUser = dataUser.createRandomTestUser(); + restClient.authenticateUser(nonInvolvedUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId("0000"); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "0000")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task cannot get task form models with invalid task id") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel.setId(""); + restClient.authenticateUser(userModel); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify user involved in task can get completed task form models") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskFormModelsForCompletedTask() throws Exception + { + UserModel assignedUser = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assignedUser); + dataWorkflow.usingUser(assignedUser).taskDone(taskModel); + dataWorkflow.usingUser(userModel).taskDone(taskModel); + restClient.authenticateUser(userModel); + returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets all task form models with properties parameter applied and response is successful (200)") public void adminGetsTaskFormModelsWithPropertiesParameter() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); returnedCollection = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,required").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); @@ -55,9 +161,10 @@ public class GetTaskFormModelFullTests extends RestTest @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets task form model with valid skipCount parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithValidSkipCount() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); returnedCollection = restClient.authenticateUser(adminUser) .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -75,9 +182,10 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with negative skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNegativeSkipCount() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("skipCount=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) @@ -89,9 +197,10 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with non numeric skipCount parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNonNumericSkipCount() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("skipCount=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); @@ -100,9 +209,10 @@ public class GetTaskFormModelFullTests extends RestTest @Bug(id = "MNT-17438") @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin gets task form model with valid maxItems parameter applied using REST API and status code is OK (200)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithValidMaxItems() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); returnedCollection = restClient.authenticateUser(adminUser) .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); @@ -120,9 +230,10 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with negative maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNegativeMaxItems() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("maxItems=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) @@ -134,19 +245,21 @@ public class GetTaskFormModelFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify admin doesn't get task form model with non numeric maxItems parameter applied using REST API") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void getTaskFormModelWithNonNumericMaxItems() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); restClient.authenticateUser(adminUser).withParams("maxItems=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() .containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify network admin user gets all task form models inside his network with Rest API and response is successful (200)") public void networkAdminGetsTaskFormModels() throws Exception { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); UserModel adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant1"); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java deleted file mode 100644 index 9bba5e6c9..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFullTests.java +++ /dev/null @@ -1,143 +0,0 @@ -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.rest.model.RestTaskModelsCollection; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class GetTaskFullTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") - public void starterUserGetsTaskWithEmptyTaskId() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); - RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); - - restClient.assertStatusCodeIs(HttpStatus.OK); - tasks.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("id", taskModel.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") - public void starterUserGetsTaskWithPropertiesParameter() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); - - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().fieldsCount().is(3) - .and().field("id").is(taskModel.getId()) - .and().field("assignee").is(taskModel.getAssignee()) - .and().field("formResourceKey").is("wf:adhocTask") - .and().field("processDefinitionId").isNull() - .and().field("processId").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") - public void starterUserGetsDeletedTask() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()); - - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(userModel).deleteProcess(process); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") - public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); - - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); - UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java deleted file mode 100644 index 9f7f638bd..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskSanityTests.java +++ /dev/null @@ -1,120 +0,0 @@ - -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -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; - - -public class GetTaskSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") - public void adminUserGetsAnyTaskWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") - public void assigneeUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") - .is(assigneeUser.getUsername()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") - public void starterUserGetsItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") - public void anyUserIsForbiddenToGetOtherTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @Bug(id = "MNT-17051") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") - public void involvedUserWithoutClaimTaskGetsTask() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java new file mode 100644 index 000000000..a0f25e0fe --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskTests.java @@ -0,0 +1,263 @@ +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.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.*; +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; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * + * @author Cristina Axinte + * + */ +public class GetTaskTests extends RestTest +{ + UserModel userModel, assigneeUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee, adminUser; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestTaskModel restTaskModel, tenantTask; + RestTaskModelsCollection taskModels; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @BeforeMethod(alwaysRun=true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets any existing task with Rest API and response is successfull (200)") + public void adminUserGetsAnyTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user gets its assigned task with Rest API and response is successfull (200)") + public void assigneeUserGetsItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()).and().field("assignee") + .is(assigneeUser.getUsername()); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task gets the started task with Rest API and response is successfull (200)") + public void starterUserGetsItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task id forbidden to get other task with Rest API (403)") + public void anyUserIsForbiddenToGetOtherTask() throws Exception + { + UserModel anyUser = dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user gets its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Bug(id = "MNT-17051") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify involved user in a task without claim it gets the task with Rest API and response is successfull (200)") + public void involvedUserWithoutClaimTaskGetsTask() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + restTaskModel = restClient.authenticateUser(userModel2).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with empty taskId with Rest API") + public void starterUserGetsTaskWithEmptyTaskId() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); + RestTaskModelsCollection tasks = restClient.processModels(RestTaskModelsCollection.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + tasks.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("id", taskModel.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task with properties parameter with Rest API") + public void starterUserGetsTaskWithPropertiesParameter() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).usingParams("properties=id,assignee,formResourceKey").getTask(); + + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().fieldsCount().is(3) + .and().field("id").is(taskModel.getId()) + .and().field("assignee").is(taskModel.getAssignee()) + .and().field("formResourceKey").is("wf:adhocTask") + .and().field("processDefinitionId").isNull() + .and().field("processId").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Verify user who started a task gets the task after it is deleted with Rest API") + public void starterUserGetsDeletedTask() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()); + + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(userModel).deleteProcess(process); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets task only from its network.") + public void adminTenantGetsTaskOnlyFromItsNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); + + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); + UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @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.REGRESSION }) + public void invalidTaskId() throws Exception + { + taskModel.setId(RandomStringUtils.randomAlphanumeric(20)); + restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .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 200 is returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void emptyTaskId() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}", ""); + taskModels = restClient.processModels(RestTaskModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @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,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void tasksInsideNetworkReturned() throws Exception + { + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); + + 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(String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())).and() + .field("processId").is(addedProcess.getId()); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java deleted file mode 100644 index f60f151ee..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksCoreTests.java +++ /dev/null @@ -1,110 +0,0 @@ -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.model.RestTaskModelsCollection; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTasksCoreTests extends RestTest -{ - UserModel userModel, userNotInvolved, candidateUser, assigneeUser, adminUser; - UserModel adminTenantUser, tenantUser, tenantUserAssignee; - SiteModel siteModel; - FileModel fileModel; - RestTaskModelsCollection taskModels, tenantTask; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - userNotInvolved = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void requestWithUserNotInvolved() throws Exception - { - taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void orderByParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(). - and().entriesListIsSortedAscBy("id"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void orderByParameterSupportsOnlyOneParameter() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); - taskModels.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void whereParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + assigneeUser.getUsername() + "')").withWorkflowAPI() - .getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", assigneeUser.getUsername()).and().entriesListCountIs(1); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void invalidOrderByParameterApplied() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void networkEnabledTasksReturned() throws Exception - { - restClient.authenticateUser(adminUser); - - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); - tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); - - restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); - - tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", - String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())); - - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java deleted file mode 100644 index b1fa28ff2..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksFullTests.java +++ /dev/null @@ -1,150 +0,0 @@ -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.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestTaskModelsCollection; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetTasksFullTests extends RestTest -{ - UserModel userModel, adminUser; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - RestTaskModelsCollection taskModels, taskCollections; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - adminUser = dataUser.getAdminUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void skipCountParameterApplied() throws Exception - { - taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); - RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); - - taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) - .assertThat().entriesListDoesNotContain("id", secondTask.getId()); - taskModels.assertThat().paginationField("skipCount").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void maxItemsParameterApplied() throws Exception - { - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); - restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); - taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) - .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); - taskModels.assertThat().paginationField("maxItems").is("2"); - taskModels.assertThat().paginationField("count").is("2"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void propertiesParameterApplied() throws Exception - { - taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty() - .assertThat().entriesListContains("name") - .assertThat().entriesListContains("description") - .assertThat().entriesListDoesNotContain("processDefinitionId") - .assertThat().entriesListDoesNotContain("processId") - .assertThat().entriesListDoesNotContain("startedAt") - .assertThat().entriesListDoesNotContain("id") - .assertThat().entriesListDoesNotContain("state") - .assertThat().entriesListDoesNotContain("activityDefinitionId") - .assertThat().entriesListDoesNotContain("priority") - .assertThat().entriesListDoesNotContain("formResourceKey"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) - .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") - public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception - { - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); - - UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); - UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - - RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks1.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant1.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); - - RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(adminTenant2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - tenantTasks2.assertThat().entriesListIsNotEmpty() - .and().entriesListCountIs(1) - .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) - .and().entriesListContains("processId", processOnTenant2.getId()) - .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) - .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java deleted file mode 100644 index 18f26dc24..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksSanityTests.java +++ /dev/null @@ -1,110 +0,0 @@ - - -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModelsCollection; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -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; - - -public class GetTasksSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - RestTaskModelsCollection taskModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") - public void adminUserGetsAllTasks() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") - public void asigneeUserGetsItsTasks() throws Exception - { - taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - @Bug(id = "MNT-16967") - public void candidateUserGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") - public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") - public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - dataWorkflow.usingUser(userModel1).claimTask(taskModel); - - taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - taskModels.assertThat().entriesListIsEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java new file mode 100644 index 000000000..1eb18a4ae --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTasksTests.java @@ -0,0 +1,292 @@ +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.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.*; +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; + +public class GetTasksTests extends RestTest +{ + UserModel userModel, userNotInvolved, assigneeUser, adminUser; + UserModel adminTenantUser, tenantUser, tenantUserAssignee; + SiteModel siteModel; + FileModel fileModel; + RestTaskModelsCollection taskModels, taskCollections, tenantTask; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + userNotInvolved = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + + assigneeUser = dataUser.createRandomTestUser(); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets all existing tasks with Rest API and response is successfull (200)") + public void adminUserGetsAllTasks() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + taskModels = restClient.authenticateUser(adminUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify asignee user gets its existing tasks with Rest API and response is successfull (200)") + public void assigneeUserGetsItsTasks() throws Exception + { + taskModels = restClient.authenticateUser(assigneeUser).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", assigneeUser.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + @Bug(id = "MNT-16967") + public void candidateUserGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user that claims the task gets its existing tasks with Rest API and response is successfull (200)") + public void candidateUserThatClaimsTaskGetsItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + taskModels = restClient.authenticateUser(userModel1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user without claim gets no tasks with Rest API and response is successfull (200)") + public void candidateUserWithoutClaimTaskGetsNoTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + dataWorkflow.usingUser(userModel1).claimTask(taskModel); + + taskModels = restClient.authenticateUser(userModel2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void skipCountParameterApplied() throws Exception + { + taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=description ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel(); + RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel(); + + taskModels = restClient.withParams("orderBy=description ASC&skipCount=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListDoesNotContain("id", firstTask.getId()) + .assertThat().entriesListDoesNotContain("id", secondTask.getId()); + taskModels.assertThat().paginationField("skipCount").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void maxItemsParameterApplied() throws Exception + { + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", assigneeUser, false, Priority.Low); + restClient.authenticateUser(userModel).withWorkflowAPI().addProcess("activitiAdhoc", adminUser, false, Priority.Low); + taskCollections = restClient.authenticateUser(userModel).withParams("orderBy=assignee ASC").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + taskModels = restClient.withParams("orderBy=startedAt DESC&maxItems=2").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("assignee", assigneeUser.getUsername()) + .assertThat().entriesListDoesNotContain("assignee", userModel.getUsername()); + taskModels.assertThat().paginationField("maxItems").is("2"); + taskModels.assertThat().paginationField("count").is("2"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void propertiesParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty() + .assertThat().entriesListContains("name") + .assertThat().entriesListContains("description") + .assertThat().entriesListDoesNotContain("processDefinitionId") + .assertThat().entriesListDoesNotContain("processId") + .assertThat().entriesListDoesNotContain("startedAt") + .assertThat().entriesListDoesNotContain("id") + .assertThat().entriesListDoesNotContain("state") + .assertThat().entriesListDoesNotContain("activityDefinitionId") + .assertThat().entriesListDoesNotContain("priority") + .assertThat().entriesListDoesNotContain("formResourceKey"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')")) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.") + public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception + { + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1"); + + UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2"); + UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + + RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks1.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant1.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant2.getId()); + + RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(adminTenant2).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTasks2.assertThat().entriesListIsNotEmpty() + .and().entriesListCountIs(1) + .and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase())) + .and().entriesListContains("processId", processOnTenant2.getId()) + .and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase())) + .and().entriesListDoesNotContain("processId", processOnTenant1.getId()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify the request in case of any user which is not involved.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void requestWithUserNotInvolved() throws Exception + { + taskModels = restClient.authenticateUser(userNotInvolved).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void orderByParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty(). + and().entriesListIsSortedAscBy("id"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that orderBy parameter is applied and supports only one parameter.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void orderByParameterSupportsOnlyOneParameter() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id,processDefinitionId").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Only one order by parameter is supported"); + taskModels.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that where parameter is applied.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void whereParameterApplied() throws Exception + { + taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("where=(assignee='" + assigneeUser.getUsername() + "')").withWorkflowAPI() + .getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + taskModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("assignee", assigneeUser.getUsername()).and().entriesListCountIs(1); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that invalid orderBy parameter applied returns 400 status code.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void invalidOrderByParameterApplied() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=invalidParameter").withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("invalidParameter is not supported"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that for network enabled only that network tasks are returned.") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void networkEnabledTasksReturned() throws Exception + { + restClient.authenticateUser(adminUser); + + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(adminTenantUser); + + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant"); + tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenantAssignee"); + + restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); + + tenantTask = restClient.authenticateUser(tenantUserAssignee).withWorkflowAPI().getTasks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + tenantTask.assertThat().entriesListIsNotEmpty().and().entriesListCountIs(1).and().entriesListContains("assignee", + String.format("userTenantAssignee@%s", tenantUserAssignee.getDomain().toLowerCase())); + + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java deleted file mode 100644 index cdfbaffdd..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import java.util.HashMap; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class UpdateTaskCoreTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - SiteModel tenantSiteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - TaskModel tenantTask; - RestTaskModel restTaskModel; - UserModel adminUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun = true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void userCanUpdateTaskWithClaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception - { - restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception - { - restClient.authenticateUser(userModel).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); - HashMap body = new HashMap(); - body.put("state", "delegated"); - body.put("assignee", assigneeUser.getUsername()); - String postBody = JsonBodyGenerator.keyValueJson(body); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), - restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - - request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") - .is(assigneeUser.getUsername()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, - TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - - restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java deleted file mode 100644 index 469e4b5b9..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk2.java +++ /dev/null @@ -1,362 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class UpdateTaskCoreTestsBulk2 extends RestTest -{ - UserModel owner; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - owner = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(owner).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can update twice task with status resolve successfully (200)") - public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") - public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception - { - String invalidJsonProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid state - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidState() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task cannot be update using a invalid property - Bad Request (400)") - public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception - { - String invalidProperty= "states"; - restClient.authenticateUser(assigneeUser) - .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); - String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task can be update using multiple select values successfully (200)") - public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", "admin").build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can complete task successfully (200)") - public void taskAssigneeCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can complete task successfully (200))") - public void taskOwnerCanCompleteTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot complete task - Forbidden (403))") - public void anyUserCannotCompleteTask() throws Exception - { - UserModel anyUser = dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priorityx") - .add("type", "d:int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d_int") - .add("value", 1) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "REPO-2062") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", "text") - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") - public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpmx_priority") - .add("type", "d:int") - .add("value", 1) - .add("scope", "globalscope").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can claim task successfully (200)") - public void taskAssigneeCanClaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can unclaim task successfully (200)") - public void taskAssigneeCanUnclaimTask() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can delegate task successfully (200)") - public void taskAssigneeCanDelegateTask() throws Exception - { - UserModel delagateToUser = dataUser.createRandomTestUser(); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", delagateToUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(delagateToUser.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can delegate task to same assignee successfully (200)") - public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(assigneeUser.getUsername()); - } - - - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to task owner - (400)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", owner.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id = "REPO-2063") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee cannot delegate task to invalid assignee - (400)") - public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception - { - UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", invalidAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java deleted file mode 100644 index d6e53b4e7..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskCoreTestsBulk3.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 12/9/2016. - */ -public class UpdateTaskCoreTestsBulk3 extends RestTest -{ - UserModel owner; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - owner = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(owner).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task assignee can update task with status resolve") - public void resolveTaskAsCurrentAssignee() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using invalid taskId") - public void updateTaskUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - taskModel.setId("invalidId"); - - restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another name") - public void updateTaskUsingAnotherName() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"newNameTask\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("name").is("newNameTask"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another description") - public void updateTaskUsingAnotherDescription() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"newDescription\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("description").is("newDescription"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherPriority() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - - restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"priority\":3}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify update task using another priority") - public void updateTaskUsingAnotherOwner() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - UserModel newOwner = dataUser.createRandomTestUser(); - - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java deleted file mode 100644 index e3ee74d64..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ /dev/null @@ -1,742 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -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.HttpMethod; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class UpdateTaskFullTestsBulk1 extends RestTest -{ - UserModel owner, anyUser; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - anyUser = dataUser.createRandomTestUser(); - owner = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(owner).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun=true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") - public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); - UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); - SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); - UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); - - restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } - - @Bug(id = "REPO-1980") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin can update only task from its network and response is 200") - public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - restClient.authenticateUser(adminUser); - - UserModel adminTenant1 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); - - UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); - UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); - SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) - .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); - - UserModel adminTenant2 = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); - - UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); - UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); - SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); - RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); - TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) - .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); - - restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel2.getId()) - .and().field("state").is("completed"); - - restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to delegated and response is 404") - public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to delegated and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to resolved and response is 404") - public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to resolved and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status completed to completed and response is 404") - public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee cannot update task from status completed to completed and response is 404") - public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception - { - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("completed"); - - restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to unclaimed and response is 200") - public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to unclaimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to delegated and response is 200") - public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to delegated and response is 200") - public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - UserModel newAssignee = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", newAssignee.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("delegated") - .and().field("assignee").is(newAssignee.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can update task from status claimed to resolved and response is 200") - public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to resolved and response is 200") - public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("resolved"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task from status claimed to claimed and response is 409") - public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify assignee can update task from status claimed to claimed and response is 200") - public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - - restTaskModel = restClient.authenticateUser(assigneeUser) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("state").is("claimed"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner can complete task with valid variables and response is 200") - public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON() - .add("name", "bpm_priority") - .add("type", "d:int") - .add("value", 3) - .add("scope", "global").build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") - .and().field("name").is("bpm_priority") - .and().field("type").is("d:int") - .and().field("value").is(3); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables array and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("priority").is(1) - .and().field("state").is("completed") - .and().field("assignee").is(taskModel.getAssignee()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot complete task with empty variables json body and response is 200") - public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "completed") - .add("variables", JsonBodyGenerator.defineJSONArray() - .add(JsonBodyGenerator.defineJSON().build()) - ).build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) - .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") - public void anyUserIsForbiddenToDelegateOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") - public void anyUserIsForbiddenToResolveOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") - public void anyUserIsForbiddenToClaimOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") - public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user cannot delegate task with emty assignee name and response is 400") - public void updateTaskWithEmptyAssigneeValue() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "delegated") - .add("assignee", "") - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner can resolve task when assignee is the owner and response is 200") - public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("state", "resolved") - .add("assignee", owner.getUsername()) - .build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("state").is("resolved") - .and().field("assignee").isNull(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify owner cannot update task after it was deleted and response is 404") - public void updateTaskAfterItWasDeleted() throws Exception - { - ProcessModel process = new ProcessModel(); - process.setId(taskModel.getProcessId()); - dataWorkflow.usingUser(owner).deleteProcess(process); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify task owner cannot update task with empty input body and response is 400") - public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); - - restTaskModel = restClient.authenticateUser(owner) - .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another name") - public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("name", "Review Task-updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another description") - public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("description", "description updated") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another dueAt") - public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "2025-01-01T11:57:32.000+0000") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", 3) - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using another priority") - public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception - { - UserModel newOwner = dataUser.createRandomTestUser(); - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("owner", newOwner.getUsername()) - .build(); - - - restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid name") - public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception - { - restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"name\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid description") - public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception - { - restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"description\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid dueAt") - public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("dueAt", "invalid-date") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON() - .add("priority", "a") - .build(); - - restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify any user cannot update task using invalid priority") - public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception - { - restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); - String postBody = "{\"owner\":\"invalid-\"a\"}"; - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); - restTaskModel = restClient.processModel(RestTaskModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) - .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java deleted file mode 100644 index 22f741646..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ /dev/null @@ -1,446 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import javax.json.JsonObject; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.JsonBodyGenerator; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -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.BeforeMethod; -import org.testng.annotations.Test; - -public class UpdateTaskFullTestsBulk2 extends RestTest -{ - private UserModel taskCreator; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - private RestTaskModel restTaskModel; - private UserModel adminUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - taskCreator = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @BeforeMethod(alwaysRun = true) - public void createTask() throws Exception - { - taskModel = dataWorkflow.usingUser(taskCreator).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", taskCreator.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularCanUpdateTaskFromUnclaimedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1924") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to completed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from delegated to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception - { - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to unclaimed by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task owner") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task cannot be updated from resolved to claimed by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to delegated by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task creator") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that task can be updated from resolved to resolved by task assignee") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception - { - restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - - restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "REPO-1982") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty select value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void updateTaskByProvidingEmptySelectValue() throws Exception - { - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) - .containsSummary(RestErrorModel.INVALID_SELECT) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty state value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void updateTaskByProvidingEmptyStateValue() throws Exception - { - restTaskModel = restClient.authenticateUser(taskCreator).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java deleted file mode 100644 index edb4670ef..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskSanityTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.alfresco.rest.workflow.tasks; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - - -public class UpdateTaskSanityTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel candidateUser; - FileModel fileModel; - UserModel assigneeUser; - TaskModel taskModel; - RestTaskModel restTaskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") - public void adminUserUpdatesAnyTaskWithSuccess() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") - public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat().field("id").is(taskModel.getId()) - .and().field("description").is(taskModel.getMessage()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") - public void starterUserUpdatesItsTaskWithSuccess() throws Exception - { - restTaskModel = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") - public void anyUserIsForbiddenToUpdateOtherTask() throws Exception - { - UserModel anyUser= dataUser.createRandomTestUser(); - - restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") - public void candidateUserUpdatesItsTasks() throws Exception - { - UserModel userModel1 = dataUser.createRandomTestUser(); - UserModel userModel2 = dataUser.createRandomTestUser(); - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - TaskModel taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); - restClient.assertStatusCodeIs(HttpStatus.OK); - restTaskModel.assertThat() - .field("dueAt").isNotEmpty() - .and().field("processDefinitionId").is("activitiReviewPooled:1:12") - .and().field("processId").is(taskModel.getProcessId()) - .and().field("name").is("Review Task") - .and().field("description").is(taskModel.getMessage()) - .and().field("startedAt").isNotEmpty() - .and().field("id").is(taskModel.getId()) - .and().field("state").is("unclaimed") - .and().field("activityDefinitionId").is("reviewTask") - .and().field("priority").is(taskModel.getPriority().getLevel()) - .and().field("formResourceKey").is("wf:activitiReviewTask"); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java new file mode 100644 index 000000000..4db6b0a89 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskTests.java @@ -0,0 +1,1722 @@ +package org.alfresco.rest.workflow.tasks; + +import java.util.HashMap; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.*; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import javax.json.JsonObject; + +public class UpdateTaskTests extends RestTest +{ + UserModel owner, anyUser; + SiteModel siteModel; + FileModel fileModel; + UserModel assigneeUser; + TaskModel taskModel; + RestTaskModel restTaskModel; + UserModel adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + owner = dataUser.createRandomTestUser(); + anyUser = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + } + + @BeforeMethod(alwaysRun = true) + public void createTask() throws Exception + { + taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify admin user updates task with Rest API and response is successfull (200)") + public void adminUserUpdatesAnyTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify assignee user updates its assigned task with Rest API and response is successfull (200)") + public void assigneeUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("description").is(taskModel.getMessage()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify user that started the task updates the started task with Rest API and response is successfull (200)") + public void starterUserUpdatesItsTaskWithSuccess() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify any user with no relation to task is forbidden to update other task with Rest API (403)") + public void anyUserIsForbiddenToUpdateOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Verify candidate user updates its specific task and no other user claimed the task with Rest API and response is successfull (200)") + public void candidateUserUpdatesItsTasks() throws Exception + { + UserModel userModel1 = dataUser.createRandomTestUser(); + UserModel userModel2 = dataUser.createRandomTestUser(); + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); + TaskModel taskModel = dataWorkflow.usingUser(owner).usingSite(siteModel).usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat() + .field("dueAt").isNotEmpty() + .and().field("processDefinitionId").is("activitiReviewPooled:1:12") + .and().field("processId").is(taskModel.getProcessId()) + .and().field("name").is("Review Task") + .and().field("description").is(taskModel.getMessage()) + .and().field("startedAt").isNotEmpty() + .and().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed") + .and().field("activityDefinitionId").is("reviewTask") + .and().field("priority").is(taskModel.getPriority().getLevel()) + .and().field("formResourceKey").is("wf:activitiReviewTask"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can update twice task with status resolve successfully (200)") + public void taskOwnerCanUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task asignee cannot update twice task with status resolve - Forbidden (403)") + public void taskAssigneeCanNotUpdateTaskWithResolveStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid json body property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidJsonBodyProperty() throws Exception + { + String invalidJsonProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson(invalidJsonProperty, "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \""+invalidJsonProperty+"\"")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid state - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidState() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("continued"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_VALUE, "task state", "continued")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task cannot be update using a invalid property - Bad Request (400)") + public void taskCanNotBeUpdatedWithInvalidSelectProperty() throws Exception + { + String invalidProperty= "states"; + restClient.authenticateUser(assigneeUser) + .withParams("select=" + invalidProperty).withWorkflowAPI().usingTask(taskModel); + String postBody = JsonBodyGenerator.keyValueJson("state", "completed"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROPERTY_DOES_NOT_EXIST, invalidProperty)); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task can be update using multiple select values successfully (200)") + public void taskCanBeUpdatedWithMultipleSelectValues() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", "admin").build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify task assignee can complete task successfully (200)") + public void taskAssigneeCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify task owner can complete task successfully (200))") + public void taskOwnerCanCompleteTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot complete task - Forbidden (403))") + public void anyUserCannotCompleteTask() throws Exception + { + UserModel anyUser = dataUser.createRandomTestUser(); + + restTaskModel = restClient.authenticateUser(anyUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2062") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid name - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidName() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priorityx") + .add("type", "d:int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"bpm_priorityx")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid Type - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidType() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d_int") + .add("value", 1) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE,"d_int")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2062") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid value - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", "text") + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "text")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with invalid scope - Bad Request(400))") + public void taskOwnerCannotCompleteTaskWithInvalidScope() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpmx_priority") + .add("type", "d:int") + .add("value", 1) + .add("scope", "globalscope").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.ILLEGAL_SCOPE, "globalscope")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can claim task successfully (200)") + public void taskAssigneeCanClaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can unclaim task successfully (200)") + public void taskAssigneeCanUnclaimTask() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can delegate task successfully (200)") + public void taskAssigneeCanDelegateTask() throws Exception + { + UserModel delagateToUser = dataUser.createRandomTestUser(); + + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", delagateToUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(delagateToUser.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can delegate task to same assignee successfully (200)") + public void taskOwnerCanDelegateTaskToSameAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(assigneeUser.getUsername()); + } + + + @Bug(id = "REPO-2063") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee cannot delegate task to task owner - (400)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotDelegateTaskToTaskOwner() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", owner.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id = "REPO-2063") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee cannot delegate task to invalid assignee - (400)") + public void taskAssigneeCannotDelegateTaskToInvalidAssignee() throws Exception + { + UserModel invalidAssignee = new UserModel("invalidAssignee", "password"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", invalidAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task assignee can update task with status resolve") + public void resolveTaskAsCurrentAssignee() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using invalid taskId") + public void updateTaskUsingInvalidTaskId() throws Exception + { + taskModel.setId("invalidId"); + + restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another name") + public void updateTaskUsingAnotherName() throws Exception + { + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"newNameTask\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("name").is("newNameTask"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another description") + public void updateTaskUsingAnotherDescription() throws Exception + { + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"newDescription\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("description").is("newDescription"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherPriority() throws Exception + { + restClient.authenticateUser(owner).withParams("select=priority").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"priority\":3}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(CMISUtil.Priority.Low.getLevel()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify update task using another priority") + public void updateTaskUsingAnotherOwner() throws Exception + { + UserModel newOwner = dataUser.createRandomTestUser(); + + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\""+newOwner.getUsername()+"\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("owner").is(newOwner.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to claimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromCompletedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromCompletedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from completed to completed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithCompleteStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from claimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromClaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user can update task from claimed to claimed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void userCanUpdateTaskWithClaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from unclaimed to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromUnclaimedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from unclaimed to unclaimed and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithUnclaimedStateTwice() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to completed and response is 422") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskFromDelegatedToCompleted() throws Exception + { + restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can not update task from delegated to delegated and response is 404") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanNotUpdateTaskWithDelegatedStateTwice() throws Exception + { + restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel); + HashMap body = new HashMap(); + body.put("state", "delegated"); + body.put("assignee", assigneeUser.getUsername()); + String postBody = JsonBodyGenerator.keyValueJson(body); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), + restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + + request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated").and().field("assignee") + .is(assigneeUser.getUsername()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, + TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify owner can update task from resolved to completed and response is 200") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromResolvedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("completed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user that created the task can update task only in its network and response is 200, for other networks is 403") + public void ownerTenantCanUpdatedTaskOnlyInItsNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); + UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); + SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); + UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); + + restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(ownerTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } + + @Bug(id = "REPO-1980") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin can update only task from its network and response is 200") + public void adminTenantCanUpdateOnlyTaskInItsNetwork() throws Exception + { + restClient.authenticateUser(adminUser); + + UserModel adminTenant1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1); + + UserModel ownerTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("ownerTenant1"); + UserModel assigneeTenant1 = dataUser.usingUser(adminTenant1).createUserWithTenant("assigneeTenant1"); + SiteModel siteModel1 = dataSite.usingUser(ownerTenant1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(ownerTenant1).usingSite(siteModel1).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def1 = restClient.authenticateUser(ownerTenant1).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel1 = dataWorkflow.usingUser(ownerTenant1).usingSite(siteModel1).usingResource(fileModel1) + .createTaskWithProcessDefAndAssignTo(def1.getId(), assigneeTenant1); + + UserModel adminTenant2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2); + + UserModel ownerTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("ownerTenant2"); + UserModel assigneeTenant2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2"); + SiteModel siteModel2 = dataSite.usingUser(ownerTenant2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(ownerTenant2).usingSite(siteModel2).createContent(DocumentType.TEXT_PLAIN); + RestProcessDefinitionModel def2 = restClient.authenticateUser(ownerTenant2).withWorkflowAPI().getAllProcessDefinitions().getEntries().get(0).onModel(); + TaskModel taskModel2 = dataWorkflow.usingUser(ownerTenant2).usingSite(siteModel2).usingResource(fileModel2) + .createTaskWithProcessDefAndAssignTo(def2.getId(), assigneeTenant2); + + restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel2).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel2.getId()) + .and().field("state").is("completed"); + + restTaskModel = restClient.authenticateUser(adminTenant2).withParams("select=state").withWorkflowAPI().usingTask(taskModel1).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to delegated and response is 404") + public void ownerCannotUpdateTaskFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to delegated and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to resolved and response is 404") + public void ownerCannotUpdateTaskFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to resolved and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status completed to completed and response is 404") + public void ownerCannotUpdateTaskFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee cannot update task from status completed to completed and response is 404") + public void assigneeCannotUpdateTaskFromCompletedToCompleted() throws Exception + { + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("completed"); + + restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .containsSummary(String.format(RestErrorModel.TASK_ALREADY_COMPLETED, taskModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to unclaimed and response is 200") + public void ownerCanUpdateTaskFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to unclaimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("unclaimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to delegated and response is 200") + public void ownerCanUpdateTaskFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to delegated and response is 200") + public void assigneeCanUpdateTaskFromClaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + UserModel newAssignee = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", newAssignee.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("delegated") + .and().field("assignee").is(newAssignee.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can update task from status claimed to resolved and response is 200") + public void ownerCanUpdateTaskFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to resolved and response is 200") + public void assigneeCanUpdateTaskFromClaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("resolved"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task from status claimed to claimed and response is 409") + public void ownerCannotUpdateTaskFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify assignee can update task from status claimed to claimed and response is 200") + public void assigneeCanUpdateTaskFromClaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(taskModel).getTask(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + + restTaskModel = restClient.authenticateUser(assigneeUser) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()) + .and().field("state").is("claimed"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner can complete task with valid variables and response is 200") + public void taskOwnerCanCompleteTaskWithValidVariables() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON() + .add("name", "bpm_priority") + .add("type", "d:int") + .add("value", 3) + .add("scope", "global").build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + RestVariableModelsCollection variables = restClient.authenticateUser(owner).withWorkflowAPI().usingTask(restTaskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variables.getVariableByName("bpm_priority").assertThat().field("scope").is("global") + .and().field("name").is("bpm_priority") + .and().field("type").is("d:int") + .and().field("value").is(3); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables array and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesArray() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("priority").is(1) + .and().field("state").is("completed") + .and().field("assignee").is(taskModel.getAssignee()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot complete task with empty variables json body and response is 200") + public void taskOwnerCannotUpdateTaskWithEmptyVariablesJsonBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "completed") + .add("variables", JsonBodyGenerator.defineJSONArray() + .add(JsonBodyGenerator.defineJSON().build()) + ).build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,variables").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to delegate other task with Rest API (403)") + public void anyUserIsForbiddenToDelegateOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("delegated"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to resolve other task with Rest API (403)") + public void anyUserIsForbiddenToResolveOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to claim other task with Rest API (403)") + public void anyUserIsForbiddenToClaimOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user with no relation to task is forbidden to unclaim other task with Rest API (403)") + public void anyUserIsForbiddenToUnclaimOtherTask() throws Exception + { + restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user cannot delegate task with emty assignee name and response is 400") + public void updateTaskWithEmptyAssigneeValue() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "delegated") + .add("assignee", "") + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner can resolve task when assignee is the owner and response is 200") + public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("state", "resolved") + .add("assignee", owner.getUsername()) + .build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("state").is("resolved") + .and().field("assignee").isNull(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify owner cannot update task after it was deleted and response is 404") + public void updateTaskAfterItWasDeleted() throws Exception + { + ProcessModel process = new ProcessModel(); + process.setId(taskModel.getProcessId()); + dataWorkflow.usingUser(owner).deleteProcess(process); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify task owner cannot update task with empty input body and response is 400") + public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().build(); + + restTaskModel = restClient.authenticateUser(owner) + .withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another name") + public void anyUserCannotUpdateTaskUsingAnotherName() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("name", "Review Task-updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=name").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another description") + public void anyUserCannotUpdateTaskUsingAnotherDescription() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("description", "description updated") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=description").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another dueAt") + public void anyUserCannotUpdateTaskUsingAnotherDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "2025-01-01T11:57:32.000+0000") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", 3) + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using another priority") + public void anyUserCannotUpdateTaskUsingAnotherOwner() throws Exception + { + UserModel newOwner = dataUser.createRandomTestUser(); + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("owner", newOwner.getUsername()) + .build(); + + + restClient.authenticateUser(anyUser).withParams("select=owner").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid name") + public void anyUserCannotUpdateTaskUsingInvalidName() throws Exception + { + restClient.authenticateUser(owner).withParams("select=name").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"name\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid description") + public void anyUserCannotUpdateTaskUsingInvalidDescription() throws Exception + { + restClient.authenticateUser(owner).withParams("select=description").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"description\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid dueAt") + public void anyUserCannotUpdateTaskUsingInvalidDueAt() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("dueAt", "invalid-date") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=dueAt").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of java.util.Date from String value 'invalid-date'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidPriority() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON() + .add("priority", "a") + .build(); + + restClient.authenticateUser(anyUser).withParams("select=priority").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Can not construct instance of int from String value 'a'")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify any user cannot update task using invalid priority") + public void anyUserCannotUpdateTaskUsingInvalidOwner() throws Exception + { + restClient.authenticateUser(owner).withParams("select=owner").withWorkflowAPI().usingTask(taskModel); + String postBody = "{\"owner\":\"invalid-\"a\"}"; + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}?{parameters}", taskModel.getId(), restClient.getParameters()); + restTaskModel = restClient.processModel(RestTaskModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unexpected character ('a'")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to claimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("claimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from unclaimed to claimed by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to delegated by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", owner.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from unclaimed to delegated by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularCanNotUpdateTaskFromUnclaimedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to unclaimed by a regular user not connected to the task") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void regularUserCannotUpdateTaskFromUnclaimedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to unclaimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("unclaimed"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from delegated to claimed since it is already claimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to claimed since it is already claimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1924") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to completed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.DELEGATED_TASK_CAN_NOT_BE_COMPLETED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from delegated to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to unclaimed by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCanUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to unclaimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task owner") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskOwnerCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task cannot be updated from resolved to claimed by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCanUpdateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(owner).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("delegated"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to delegated by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved by task creator") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskCreatorCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from resolved to resolved by task assignee") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void taskAssigneeCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(adminUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError() + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1982") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty select value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskByProvidingEmptySelectValue() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(RestErrorModel.INVALID_SELECT_ERRORKEY) + .containsSummary(RestErrorModel.INVALID_SELECT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Update task by providing empty state value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void updateTaskByProvidingEmptyStateValue() throws Exception + { + restTaskModel = restClient.authenticateUser(owner).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " ")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java deleted file mode 100644 index eaa4bcf0f..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesCoreTests.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.alfresco.rest.workflow.tasks.candidates; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -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.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 bogdan.bocancea - * - */ - -public class GetTaskCandidatesCoreTests extends RestTest -{ - private UserModel userModel, userModel1, userModel2; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private GroupModel group; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userModel1 = dataUser.createRandomTestUser(); - userModel2 = dataUser.createRandomTestUser(); - group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with invalid task id") - public void getTaskCandidatesWithInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId("invalid-id"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates with empty task id") - public void getTaskCandidatesWithEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - taskModel.setId(""); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates for completed task") - public void getTaskCandidatesForCompletedTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - dataWorkflow.usingUser(userModel1).taskDone(taskModel); - - restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify get task candidates by non candidate user") - public void getTaskCandidatesByNonCandidateUser() throws Exception - { - UserModel outsider = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java similarity index 74% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java index aebaa0707..353e3bff6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/candidates/GetTaskCandidatesRegressionTests.java @@ -22,7 +22,7 @@ import org.testng.annotations.Test; * @author bogdan.bocancea * */ -public class GetTaskCandidatesFullTests extends RestTest +public class GetTaskCandidatesRegressionTests extends RestTest { private UserModel userModel, userModel1, userModel2; private SiteModel siteModel; @@ -43,6 +43,71 @@ public class GetTaskCandidatesFullTests extends RestTest dataGroup.addListOfUsersToGroup(group, userModel1, userModel2); } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with invalid task id") + public void getTaskCandidatesWithInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId("invalid-id"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalid-id")); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates with empty task id") + public void getTaskCandidatesWithEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + taskModel.setId(""); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates for completed task") + public void getTaskCandidatesForCompletedTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + dataWorkflow.usingUser(userModel1).taskDone(taskModel); + + restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify get task candidates by non candidate user") + public void getTaskCandidatesByNonCandidateUser() throws Exception + { + UserModel outsider = dataUser.createRandomTestUser(); + taskModel = dataWorkflow.usingUser(userModel) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + restClient.authenticateUser(outsider).withWorkflowAPI().usingTask(taskModel).getTaskCandidates(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check default error model schema for get task candidates") @@ -59,7 +124,7 @@ public class GetTaskCandidatesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @Bug(id="MNT-17438") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, @@ -76,7 +141,7 @@ public class GetTaskCandidatesFullTests extends RestTest .entriesListIsNotEmpty() .and().paginationField("count").is("0"); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with max items parameter set to 0") @@ -93,7 +158,7 @@ public class GetTaskCandidatesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with max items parameter") @@ -109,7 +174,7 @@ public class GetTaskCandidatesFullTests extends RestTest .entriesListIsNotEmpty() .and().paginationField("count").is("1"); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with properties") @@ -125,7 +190,7 @@ public class GetTaskCandidatesFullTests extends RestTest .field("candidateId").contains(group.getGroupIdentifier()).and() .field("candidateType").isNull(); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates with invalid properties") @@ -140,7 +205,7 @@ public class GetTaskCandidatesFullTests extends RestTest candidateModels.getEntries().get(0).onModel().assertThat() .fieldsCount().is(0).and(); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by deleted candidate") @@ -152,9 +217,9 @@ public class GetTaskCandidatesFullTests extends RestTest restClient.authenticateUser(userModel1).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.OK); - + dataUser.usingAdmin().deleteUser(userModel1); - + restClient.authenticateUser(userModel1).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) @@ -163,7 +228,7 @@ public class GetTaskCandidatesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by deleted group") @@ -178,9 +243,9 @@ public class GetTaskCandidatesFullTests extends RestTest restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.OK); - + dataGroup.usingAdmin().deleteGroup(deletedGroup); - + restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) @@ -188,7 +253,7 @@ public class GetTaskCandidatesFullTests extends RestTest .containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) .stackTraceIs(RestErrorModel.STACKTRACE); } - + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Get task candidates by user that was removed from group") @@ -202,9 +267,9 @@ public class GetTaskCandidatesFullTests extends RestTest restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.OK); - + dataGroup.usingAdmin().removeUserFromGroup(group, newUser); - + restClient.authenticateUser(newUser).withWorkflowAPI() .usingTask(taskModel).getTaskCandidates(); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java index 6e5b66bc7..f44a27c38 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk1.java @@ -21,7 +21,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskItemSanityTests extends RestTest +public class AddTaskItemTestsBulk1 extends RestTest { private UserModel userModel, userWhoStartsTask, assigneeUser; private SiteModel siteModel; @@ -96,9 +96,9 @@ public class AddTaskItemSanityTests extends RestTest .assertThat().field("mimeType").is(taskItems.getEntries().get(1).onModel().getMimeType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in case task item exists the request fails") public void createTaskItemThatAlreadyExists() throws Exception { @@ -122,9 +122,9 @@ public class AddTaskItemSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @Bug(id = "MNT-16966") - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that in case task item exists the request fails") public void createMultipleTaskItemThatAlreadyExists() throws Exception { @@ -160,10 +160,10 @@ public class AddTaskItemSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); } - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add task item using admin user from same network") - public void addTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception + public void addTaskItemByAdminSameNetwork() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); @@ -190,10 +190,10 @@ public class AddTaskItemSanityTests extends RestTest .and().field("mimeType").is(taskItem.getMimeType()); } - @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.NETWORKS,TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add task item using admin user from same network") - public void addMultipleTaskItemByAdminSameNetwork() throws JsonToModelConversionException, Exception + public void addMultipleTaskItemByAdminSameNetwork() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java similarity index 94% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java index 911725f2b..2b1d0b5eb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk2.java @@ -19,7 +19,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskItemCoreTests extends RestTest +public class AddTaskItemTestsBulk2 extends RestTest { private UserModel userModel, assigneeUser, anotherUser; private SiteModel siteModel; @@ -40,10 +40,10 @@ public class AddTaskItemCoreTests extends RestTest taskId = taskModel.getId(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") - public void addTaskItemByRandomUser() throws JsonToModelConversionException, Exception + public void addTaskItemByRandomUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); @@ -56,10 +56,10 @@ public class AddTaskItemCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add multiple task item using random user.") - public void addMultipleTaskItemByRandomUser() throws JsonToModelConversionException, Exception + public void addMultipleTaskItemByRandomUser() throws Exception { anotherUser = dataUser.createRandomTestUser(); restClient.authenticateUser(anotherUser).withWorkflowAPI().usingTask(taskModel) @@ -73,7 +73,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item, is falling in case invalid itemBody is provided") public void failedAddingTaskItemIfInvalidItemBodyIsProvided() throws Exception @@ -89,7 +89,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5683") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task item, is falling in case invalid itemBody is provided") public void failedAddingMultipleTaskItemIfInvalidItemBodyIsProvided() throws Exception @@ -106,7 +106,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case empty item body is provided") public void failedAddingTaskItemIfEmptyItemBodyIsProvided() throws Exception @@ -119,7 +119,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task item is falling in case empty item body is provided") public void failedAddingMultipleTaskItemIfEmptyItemBodyIsProvided() throws Exception @@ -131,7 +131,7 @@ public class AddTaskItemCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(""); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") public void failedAddingTaskItemIfInvalidTaskIdIsProvided() throws Exception @@ -146,7 +146,7 @@ public class AddTaskItemCoreTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE);; } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case invalid task id is provided") public void failedAddingMultipleTaskItemIfInvalidTaskIdIsProvided() throws Exception @@ -162,7 +162,7 @@ public class AddTaskItemCoreTests extends RestTest } @Bug(id = "ACE-5675") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task item is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java similarity index 98% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java index c929d2652..447d0d27d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/AddTaskItemTestsBulk3.java @@ -20,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskItemFullTests extends RestTest +public class AddTaskItemTestsBulk3 extends RestTest { private UserModel userModel, adminUser,userWhoStartsTask, assigneeUser; private SiteModel siteModel; @@ -44,7 +44,7 @@ public class AddTaskItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add task item using random user.") - public void addTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception + public void addTaskItemByTheUserThatStartedTheProcess() throws Exception { taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(fileModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); @@ -62,7 +62,7 @@ public class AddTaskItemFullTests extends RestTest @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Add multiple task item using random user.") - public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws JsonToModelConversionException, Exception + public void addMultipleTaskItemByTheUserThatStartedTheProcess() throws Exception { fileModel1 = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); taskItems = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel) @@ -168,7 +168,7 @@ public class AddTaskItemFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete multiple task item then create it again") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL}) - public void deleteMultipleTaskItemThenCreateItAgain() throws Exception + public void deleteMultipleTaskItemsThenCreateThemAgain() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel) .createNewTaskAndAssignTo(assigneeUser); @@ -187,5 +187,4 @@ public class AddTaskItemFullTests extends RestTest restClient.withWorkflowAPI().usingTask(taskModel).addTaskItems(document2, document1, document3); restClient.assertStatusCodeIs(HttpStatus.CREATED); } - - } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java deleted file mode 100644 index 8b853dac7..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsCoreTests.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -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.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.utility.model.FileModel; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 12/8/2016. - */ -public class GetTaskItemsCoreTests extends RestTest -{ - private UserModel adminUser, userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestItemModelsCollection itemModels; - private RestProcessModel addedProcess; - private RestTaskModel addedTask; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - adminUser = dataUser.getAdminUser(); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task items call return status code 404 when invalid taskId is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskItemsUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the task is finished.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskItemsAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - restClient.authenticateUser(userWhoStartsTask); - itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, - executionType = ExecutionType.REGRESSION, - description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void getTaskItemsAfterDeletingProcess() throws Exception - { - addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call with admin from different network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE, TestGroup.NETWORKS }) - public void getTaskItemsByAdminFromAnotherNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); - UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); - - siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); - addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); - addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); - - restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify gets task items call returns only task items inside network") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE, TestGroup.NETWORKS }) - public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception - { - UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); - UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); - - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); - restClient.usingTenant().createTenant(adminTenantUser2); - - UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); - UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); - - SiteModel siteModel1 = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); - FileModel fileModel1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel1).createContent(DocumentType.XML); - - RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); - RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); - RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); - - SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); - FileModel fileModel2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(DocumentType.XML); - - RestProcessModel addedProcess2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser2, false, Priority.Normal); - RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); - RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); - - itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem2.getId()).and() - .entriesListContains("name", fileModel2.getName()).and() - .entriesListDoesNotContain("id", taskItem1.getId()).and() - .entriesListDoesNotContain("name", fileModel1.getName()); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java deleted file mode 100644 index 9bc9d7046..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsFullTests.java +++ /dev/null @@ -1,199 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.rest.model.RestItemModelsCollection; -import org.alfresco.utility.model.FileModel; -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; - -public class GetTaskItemsFullTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestItemModelsCollection itemModels; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error model schema for get task items api call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void getTaskItemsUsingCheckErrorModel() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - restClient.authenticateUser(assignee).withWorkflowAPI() - .usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that admin user can get task items") - public void getTaskItemsByAdminUser() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - - itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty().and() - .entriesListContains("id", taskItem.onModel().getId()).and() - .entriesListContains("name", taskItem.onModel().getName()) - .getEntries().get(0).onModel() - .assertThat().field("createdAt").isNotNull() - .assertThat().field("size").isNotNull() - .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) - .assertThat().field("modifiedAt").isNotNull() - .assertThat().field("name").contains(fileModel.getName()) - .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) - .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) - .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with skip count parameter") - public void getTaskItemsWithSkipCount() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Bug(id="MNT-17438") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with max items parameter") - public void getTaskItemsWithMaxItems() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.assertThat() - .entriesListIsNotEmpty() - .and().paginationField("count").is("1"); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with valid properties") - public void getTaskItemsWithValidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(4).and() - .field("createdAt").isNotNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNotNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNotNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that user who started the process can get task items with an invalid property") - public void getTaskItemsWithInvalidProperties() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); - itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.OK); - itemModels.getOneRandomEntry().onModel().assertThat() - .fieldsCount().is(1).and() - .field("createdAt").isNull().and() - .field("size").isNotNull().and() - .field("createdBy").isNull().and() - .field("modifiedAt").isNull().and() - .field("name").isNull().and() - .field("modifiedBy").isNull().and() - .field("id").isNull().and() - .field("mimeType").isNull(); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was deleted cannot get task items") - public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception - { - UserModel assigneeDeleted = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); - - dataUser.usingAdmin().deleteUser(assigneeDeleted); - - itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } - - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that involved user in process that was disabled cannot get task items") - public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception - { - UserModel assigneeDisabled = dataUser.createRandomTestUser(); - restClient.authenticateUser(userWhoStartsTask); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); - - dataUser.usingAdmin().disableUser(assigneeDisabled); - - itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java new file mode 100644 index 000000000..74bc978b7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/GetTaskItemsRegressionTests.java @@ -0,0 +1,324 @@ +package org.alfresco.rest.workflow.tasks.items; + +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.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.utility.model.FileModel; +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; + +/** + * Created by Claudia Agache on 12/8/2016. + */ +public class GetTaskItemsRegressionTests extends RestTest +{ + private UserModel adminUser, userWhoStartsTask, assignee; + private SiteModel siteModel; + private FileModel fileModel; + private TaskModel taskModel; + private RestItemModelsCollection itemModels; + private RestProcessModel addedProcess; + private RestTaskModel addedTask; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task items call return status code 404 when invalid taskId is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsUsingInvalidTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); + + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the task is finished.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + restClient.authenticateUser(userWhoStartsTask); + itemModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get task items request returns status code 200 after the process is deleted (Task state is now completed.)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsAfterDeletingProcess() throws Exception + { + addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat().entriesListIsNotEmpty().and().entriesListContains("name", fileModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call with admin from different network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsByAdminFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant"); + UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenantAssignee"); + + siteModel = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + fileModel = dataContent.usingUser(adminTenantUser1).usingSite(siteModel).createContent(DocumentType.XML); + addedProcess = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Normal); + addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingTask(addedTask).addTaskItem(fileModel); + + restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingTask(addedTask).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify gets task items call returns only task items inside network") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getTaskItemsReturnsOnlyItemsFromThatNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + restClient.usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); + + SiteModel siteModel1 = dataSite.usingUser(adminTenantUser1).createPublicRandomSite(); + FileModel fileModel1 = dataContent.usingUser(adminTenantUser1).usingSite(siteModel1).createContent(DocumentType.XML); + + RestProcessModel addedProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + RestTaskModel addedTask1 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess1); + RestItemModel taskItem1 = restClient.withWorkflowAPI().usingTask(addedTask1).addTaskItem(fileModel1); + + SiteModel siteModel2 = dataSite.usingUser(adminTenantUser2).createPublicRandomSite(); + FileModel fileModel2 = dataContent.usingUser(adminTenantUser2).usingSite(siteModel2).createContent(DocumentType.XML); + + RestProcessModel addedProcess2 = restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUser2, false, Priority.Normal); + RestTaskModel addedTask2 = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess2); + RestItemModel taskItem2 = restClient.withWorkflowAPI().usingTask(addedTask2).addTaskItem(fileModel2); + + itemModels = restClient.withWorkflowAPI().usingTask(addedTask2).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem2.getId()).and() + .entriesListContains("name", fileModel2.getName()).and() + .entriesListDoesNotContain("id", taskItem1.getId()).and() + .entriesListDoesNotContain("name", fileModel1.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error model schema for get task items api call") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void getTaskItemsUsingCheckErrorModel() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId("invalidId"); + restClient.authenticateUser(assignee).withWorkflowAPI() + .usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin user can get task items") + public void getTaskItemsByAdminUser() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + + itemModels = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty().and() + .entriesListContains("id", taskItem.onModel().getId()).and() + .entriesListContains("name", taskItem.onModel().getName()) + .getEntries().get(0).onModel() + .assertThat().field("createdAt").isNotNull() + .assertThat().field("size").isNotNull() + .assertThat().field("createdBy").contains(dataUser.getAdminUser().getUsername()) + .assertThat().field("modifiedAt").isNotNull() + .assertThat().field("name").contains(fileModel.getName()) + .assertThat().field("modifiedBy").contains(userWhoStartsTask.getUsername()) + .assertThat().field("id").contains(fileModel.getNodeRef().split(";")[0]) + .assertThat().field("mimeType").contains(fileModel.getFileType().mimeType); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with skip count parameter") + public void getTaskItemsWithSkipCount() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("skipCount=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Bug(id="MNT-17438") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with max items parameter") + public void getTaskItemsWithMaxItems() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + FileModel document1 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document1); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("maxItems=1").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.assertThat() + .entriesListIsNotEmpty() + .and().paginationField("count").is("1"); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with valid properties") + public void getTaskItemsWithValidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=createdAt,createdBy,id,size").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(4).and() + .field("createdAt").isNotNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNotNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNotNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user who started the process can get task items with an invalid property") + public void getTaskItemsWithInvalidProperties() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems().getOneRandomEntry(); + itemModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .usingParams("properties=size,fake-prop").usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.OK); + itemModels.getOneRandomEntry().onModel().assertThat() + .fieldsCount().is(1).and() + .field("createdAt").isNull().and() + .field("size").isNotNull().and() + .field("createdBy").isNull().and() + .field("modifiedAt").isNull().and() + .field("name").isNull().and() + .field("modifiedBy").isNull().and() + .field("id").isNull().and() + .field("mimeType").isNull(); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was deleted cannot get task items") + public void getTaskItemsByDeletedUserInvolvedInProcess() throws Exception + { + UserModel assigneeDeleted = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDeleted); + + dataUser.usingAdmin().deleteUser(assigneeDeleted); + + itemModels = restClient.authenticateUser(assigneeDeleted).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that involved user in process that was disabled cannot get task items") + public void getTaskItemsByDisabledUserInvolvedInProcess() throws Exception + { + UserModel assigneeDisabled = dataUser.createRandomTestUser(); + restClient.authenticateUser(userWhoStartsTask); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeDisabled); + + dataUser.usingAdmin().disableUser(assigneeDisabled); + + itemModels = restClient.authenticateUser(assigneeDisabled).withWorkflowAPI().usingTask(taskModel).getTaskItems(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java deleted file mode 100644 index b72978e0e..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemCoreTests.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.GroupModel; -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 bogdan.bocancea - */ -public class RemoveTaskItemCoreTests extends RestTest -{ - private UserModel userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty item id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemEmptyItemId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for completed task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemForCompletedTask() throws Exception - { - TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); - dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); - dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); - restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with candidate user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemWithCandidateUser() throws Exception - { - GroupModel group = dataGroup.createRandomGroup(); - dataGroup.addListOfUsersToGroup(group, assigneeUser); - TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); - - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); - restClient.authenticateUser(assigneeUser) - .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with unauthorized user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemWithUnauthorizedUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - UserModel unauthorizedUser = dataUser.createRandomTestUser(); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskItemWithInexistentUser() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item for deleted task") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskItemFromDeletedProcess() throws Exception - { - ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel) - .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); - TaskModel task = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); - - document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); - dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); - restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java deleted file mode 100644 index 8d334062d..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemFullTests.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.FileModel; -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.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 bogdan.bocancea - */ -public class RemoveTaskItemFullTests extends RestTest -{ - private UserModel userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskItemTwice() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with locked document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskItemWithLockedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.CONFLICT) - .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task item with deleted document") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) - public void deleteTaskItemWithDeletedDocument() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - - dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); - - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java deleted file mode 100644 index 4bff98e35..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemSanityTests.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.alfresco.rest.workflow.tasks.items; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestItemModel; -import org.alfresco.utility.model.FileModel; -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.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 iulia.cojocea - */ -public class RemoveTaskItemSanityTests extends RestTest -{ - private UserModel adminUser, userModel, userWhoStartsTask, assigneeUser; - private SiteModel siteModel; - private FileModel fileModel, document2; - private TaskModel taskModel; - - private RestItemModel taskItem; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task item") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItem() throws Exception - { - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() - .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() - .entriesListDoesNotContain("name", document2.getName()); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Try to Delete existing task item using invalid taskId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItemUsingInvalidTaskId() throws Exception - { - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId("invalidTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Try to Delete existing task item using invalid itemId") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskItemUsingInvalidItemId() throws Exception - { - restClient.authenticateUser(adminUser); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskItem.setId("incorrectItemId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java new file mode 100644 index 000000000..d31b5469b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -0,0 +1,253 @@ +package org.alfresco.rest.workflow.tasks.items; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.utility.model.*; +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 bogdan.bocancea + */ +public class RemoveTaskItemTests extends RestTest +{ + private UserModel adminUser, userWhoStartsTask, assigneeUser; + private SiteModel siteModel; + private FileModel fileModel, document2; + private TaskModel taskModel; + private RestItemModel taskItem; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + assigneeUser = dataUser.createRandomTestUser(); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskItem() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskItems() + .assertThat().entriesListDoesNotContain("id", taskItem.getId()).and() + .entriesListDoesNotContain("name", document2.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to Delete existing task item using invalid taskId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemUsingInvalidTaskId() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskModel.setId("invalidTaskId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTaskId")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to Delete existing task item using invalid itemId") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemUsingInvalidItemId() throws Exception + { + restClient.authenticateUser(adminUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem.setId("incorrectItemId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskModel.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with empty item id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemEmptyItemId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + taskItem.setId(""); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for completed task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemForCompletedTask() throws Exception + { + TaskModel completedTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(completedTask).addTaskItem(document2); + dataWorkflow.usingUser(assigneeUser).taskDone(completedTask); + dataWorkflow.usingUser(userWhoStartsTask).taskDone(completedTask); + restClient.withWorkflowAPI().usingTask(completedTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, completedTask.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item with candidate user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskItemWithCandidateUser() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(group, assigneeUser); + TaskModel groupTask = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createPooledReviewTaskAndAssignTo(group); + + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(groupTask).addTaskItem(document2); + restClient.authenticateUser(assigneeUser) + .withWorkflowAPI().usingTask(groupTask).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item with unauthorized user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithUnauthorizedUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + UserModel unauthorizedUser = dataUser.createRandomTestUser(); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(unauthorizedUser).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task item with inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void deleteTaskItemWithInexistentUser() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete existing task item for deleted task") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemFromDeletedProcess() throws Exception + { + ProcessModel deletedProcess = dataWorkflow.usingUser(userWhoStartsTask) + .usingSite(siteModel) + .usingResource(fileModel).createMoreReviewersWorkflowAndAssignTo(assigneeUser); + TaskModel task = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingProcess(deletedProcess).getProcessTasks().getEntries().get(0).onModel(); + + document2 = dataContent.usingUser(userWhoStartsTask).usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(task).addTaskItem(document2); + dataWorkflow.usingUser(userWhoStartsTask).deleteProcess(deletedProcess); + restClient.withWorkflowAPI().usingTask(task).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, task.getId())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item twice") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemTwice() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with locked document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithLockedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).checkOutDocument(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT) + .assertLastError().containsSummary(String.format(RestErrorModel.LOCKED_NODE_OPERATION, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task item with deleted document") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskItemWithDeletedDocument() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + restClient.authenticateUser(userWhoStartsTask); + document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); + taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); + + dataContent.usingUser(userWhoStartsTask).usingResource(document2).deleteContent(); + + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, document2.getNodeRefWithoutVersion())) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java index 86cd6c2cb..03dac2155 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk1.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; * @author iulia.cojocea */ -public class AddTaskVariablesSanityTests extends RestTest +public class AddTaskVariablesTestsBulk1 extends RestTest { private UserModel userModel, userWhoStartsTask; private SiteModel siteModel; @@ -59,8 +59,8 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create non-existing task variable with admin") public void createMultipleTaskVariablesWithAdmin() throws Exception { @@ -103,8 +103,8 @@ public class AddTaskVariablesSanityTests extends RestTest restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables().assertThat().entriesListContains("name", variableModel.getName()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple non-existing task variable with involved user") public void createMultipleTaskVariableWithInvolvedUser() throws Exception { @@ -144,8 +144,8 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple non-existing task variable with task owner") public void createMultipleTaskVariableWithTaskOwner() throws Exception { @@ -169,8 +169,8 @@ public class AddTaskVariablesSanityTests extends RestTest .and().field("type").is(variableModel1.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create non-existing task variable with any user") public void createTaskVariableWithRandomUser() throws Exception { @@ -182,8 +182,8 @@ public class AddTaskVariablesSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied"); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple non-existing task variable with any user") public void createMultipleTaskVariableWithRandomUser() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java index 9efbdd957..fd2704692 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk2.java @@ -19,7 +19,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskVariablesCoreTests extends RestTest +public class AddTaskVariablesTestsBulk2 extends RestTest { private UserModel userWhoStartsTask, adminUser; private SiteModel siteModel; @@ -44,7 +44,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.authenticateUser(adminUser); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception { @@ -54,7 +54,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid variableBody is provided") public void failedAddingMultipleTaskVariableIfInvalidBodyIsProvided() throws Exception @@ -66,7 +66,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception { @@ -77,7 +77,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary("Variable scope is required and can only be 'local' or 'global'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case empty body type is provided") public void failedAddingMultipleTaskVariableIfEmptyBodyIsProvided() throws Exception @@ -90,7 +90,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary("Variable scope is required and can only be 'local' or 'global'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception { @@ -102,7 +102,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary("Variable scope is required and can only be 'local' or 'global'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception { @@ -113,7 +113,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception { @@ -124,7 +124,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid type is provided") public void failedAddingMultipleTaskVariableIfInvalidTypeIsProvided() throws Exception @@ -138,7 +138,7 @@ public class AddTaskVariablesCoreTests extends RestTest } @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception { @@ -150,7 +150,7 @@ public class AddTaskVariablesCoreTests extends RestTest } @Bug(id = "ACE-5674") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid type prefix is provided") public void failedAddingMultipleTaskVariableIfInvalidTypePrefixIsProvided() throws Exception @@ -164,7 +164,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception { @@ -175,7 +175,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid scope is provided") public void failedAddingMultipleTaskVariableIfInvalidScopeIsProvided() throws Exception @@ -189,7 +189,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception { @@ -201,7 +201,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid task id is provided") public void failedAddingMultipleTaskVariableIfInvalidTaskIdIsProvided() throws Exception @@ -215,7 +215,7 @@ public class AddTaskVariablesCoreTests extends RestTest .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception { @@ -226,7 +226,7 @@ public class AddTaskVariablesCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding multiple task variable is falling in case invalid task id is provided") public void failedAddingMultipleTaskVariableIfInvalidValueIsProvided() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java index a2fbf7b95..b82b8f675 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/AddTaskVariablesTestsBulk3.java @@ -22,7 +22,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class AddTaskVariablesFullTests extends RestTest +public class AddTaskVariablesTestsBulk3 extends RestTest { private UserModel userWhoStartsTask, adminUser; private SiteModel siteModel; @@ -46,7 +46,7 @@ public class AddTaskVariablesFullTests extends RestTest taskId = taskModel.getId(); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with name containing symbols") public void createTaskVariableWithSymbolsInName() throws Exception @@ -64,7 +64,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create multiple task variable with name containing symbols") public void createMultipleTaskVariableWithSymbolsInName() throws Exception @@ -90,7 +90,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel1.getType()); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with empty name") public void createTaskVariableWithEmptyName() throws Exception @@ -109,7 +109,7 @@ public class AddTaskVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid variable name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void createTaskVariableWithInvalidVariableName() throws Exception { restClient.authenticateUser(adminUser).withWorkflowAPI(); @@ -124,7 +124,7 @@ public class AddTaskVariablesFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with invalid name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void createTaskVariableWithInvalidName() throws Exception { restClient.authenticateUser(adminUser).withWorkflowAPI(); @@ -137,10 +137,10 @@ public class AddTaskVariablesFullTests extends RestTest .containsSummary(String.format(RestErrorModel.NO_CONTENT,"Unexpected character " + "('''")); } - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Create task variable with empty name") - public void failledCreatingMultipleTaskVariableWithEmptyName() throws Exception + public void failedCreatingMultipleTaskVariableWithEmptyName() throws Exception { UserModel adminUser = dataUser.getAdminUser(); restClient.authenticateUser(adminUser); @@ -156,7 +156,7 @@ public class AddTaskVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to add task variables") public void addTaskVariablesByTenantAdmin() throws Exception @@ -182,7 +182,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel.getType()); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to add multiple task variables") public void addMultipleTaskVariablesByTenantAdmin() throws Exception @@ -216,7 +216,7 @@ public class AddTaskVariablesFullTests extends RestTest .and().field("type").is(variableModel1.getType()); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to add task variables") public void addTaskVariablesByTenantFromAnotherNetwork() throws Exception @@ -242,7 +242,7 @@ public class AddTaskVariablesFullTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to add multiple task variables") public void addMultipleTaskVariablesByTenantFromAnotherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java deleted file mode 100644 index 6b475c6db..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableCoreTests.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -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 bogdan.bocancea - */ -public class DeleteTaskVariableCoreTests extends RestTest -{ - private UserModel userModel; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid type") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableInvalidType() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setType("invalid-type"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - . assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable with invalid name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableInvalidName() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Create, update, delete task variable with any user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void createUpdateDeleteTaskVarialbleByAnyUser() throws Exception - { - restClient.authenticateUser(userModel); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - variableModel.setName("new-variable"); - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by non assigned user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - public void deleteTaskVariableByNonAssignedUser() throws Exception - { - UserModel nonAssigned = dataUser.createRandomTestUser(); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete task variable by inexistent user") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void deleteTaskVariableByInexistentUser() throws Exception - { - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.authenticateUser(UserModel.getRandomUserModel()) - .withWorkflowAPI() - .usingTask(taskModel) - .deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java deleted file mode 100644 index ba8ae1e73..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableSanityTests.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestVariableModel; -import org.alfresco.utility.model.FileModel; -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.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 iulia.cojocea - */ -public class DeleteTaskVariableSanityTests extends RestTest -{ - private UserModel userModel, adminUser; - private SiteModel siteModel; - private FileModel fileModel; - private UserModel assigneeUser; - private TaskModel taskModel; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - assigneeUser = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Delete existing task variable") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void deleteTaskVariable() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Try to delete existing task variable using invalid task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception - { - restClient.authenticateUser(adminUser); - RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); - - restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); - taskModel.setId("incorrectTaskId"); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java similarity index 54% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java index e405a0278..e0c5f8e0d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/DeleteTaskVariableTests.java @@ -12,6 +12,7 @@ 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; @@ -21,9 +22,9 @@ import org.testng.annotations.Test; /** * @author bogdan.bocancea */ -public class DeleteTaskVariableFullTests extends RestTest +public class DeleteTaskVariableTests extends RestTest { - private UserModel userModel; + private UserModel userModel, assigneeUser, adminUser; private SiteModel siteModel; private FileModel fileModel; private TaskModel taskModel; @@ -31,15 +32,135 @@ public class DeleteTaskVariableFullTests extends RestTest @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userModel = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(userModel); + taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete existing task variable") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskVariable() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Try to delete existing task variable using invalid task id") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void tryToDeleteTaskVariableUsingInvalidTaskId() throws Exception + { + restClient.authenticateUser(adminUser); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + taskModel.setId("incorrectTaskId"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + public void deleteTaskVariableByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid type") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableInvalidType() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setType("invalid-type"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + . assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable with invalid name") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableInvalidName() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = new RestVariableModel("local", "<>.,;/|-+=%", "d:text", "invalid name"); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Create, update, delete task variable with any user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void createUpdateDeleteTaskVariableByAnyUser() throws Exception + { + restClient.authenticateUser(userModel); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + variableModel.setName("new-variable"); + restClient.withWorkflowAPI().usingTask(taskModel).updateTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by non assigned user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + public void deleteTaskVariableByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Delete task variable by inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void deleteTaskVariableByInexistentUser() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + restClient.authenticateUser(UserModel.getRandomUserModel()) + .withWorkflowAPI() + .usingTask(taskModel) + .deleteTaskVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable twice") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskVariableTwice() throws Exception { restClient.authenticateUser(userModel); @@ -61,7 +182,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with empty variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskEmptyVariableName() throws Exception { restClient.authenticateUser(userModel); @@ -79,7 +200,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with empty variable scope") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskEmptyVariableScope() throws Exception { restClient.authenticateUser(userModel); @@ -96,7 +217,7 @@ public class DeleteTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with invalid variable name") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void deleteTaskInvalidVariableName() throws Exception { restClient.authenticateUser(userModel); @@ -112,7 +233,7 @@ public class DeleteTaskVariableFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to remove task variables") public void addTaskVariablesByTenantAdmin() throws Exception @@ -136,7 +257,7 @@ public class DeleteTaskVariableFullTests extends RestTest } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the other network is not able to remove task variables") public void addTaskVariablesByTenantAdminOtherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java deleted file mode 100644 index d0e788191..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesCoreTests.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestProcessModel; -import org.alfresco.rest.model.RestTaskModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -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.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Created by Claudia Agache on 12/7/2016. - */ - -public class GetTaskVariablesCoreTests extends RestTest -{ - private UserModel userWhoStartsTask, assignee; - private SiteModel siteModel; - private FileModel fileModel; - private TaskModel taskModel; - private RestVariableModelsCollection variableModels; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when invalid taskId is used") - public void getTaskVariablesUsingInvalidTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId("invalidId"); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 404 when empty taskId is used") - public void getTaskVariablesUsingEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - taskModel.setId(""); - - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the task is finished.") - public void getTaskVariablesAfterFinishingTask() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - dataWorkflow.usingUser(assignee).taskDone(taskModel); - - variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") - public void getTaskVariablesAfterDeletingProcess() throws Exception - { - RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); - RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); - restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets task variables that matches a where clause.") - public void getTaskVariablesWithWhereClauseAsParameter() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty() - .and().entriesListDoesNotContain("scope", "global") - .and().paginationField("totalItems").is("8"); - - variableModels = restClient.authenticateUser(userWhoStartsTask) - .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListContains("scope", "global") - .and().paginationField("totalItems").is("30"); - } - -} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java deleted file mode 100644 index f6d249f05..000000000 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesSanityTests.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.alfresco.rest.workflow.tasks.variables; - -import org.alfresco.dataprep.CMISUtil.DocumentType; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestVariableModelsCollection; -import org.alfresco.utility.model.FileModel; -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.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 iulia.cojocea - */ - -public class GetTaskVariablesSanityTests extends RestTest -{ - 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 - { - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that started the process gets task variables") - public void getTaskVariablesByUserWhoStartedProcess() throws Exception - { - restClient.authenticateUser(userWhoStartsTask); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is involved in the process gets task variables") - public void getTaskVariablesByUserInvolvedInProcess() throws Exception - { - restClient.authenticateUser(assignee); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that user that is not involved in the process gets task variables") - public void getTaskVariablesUsingAnyUser() throws Exception - { - UserModel randomUser = dataUser.createRandomTestUser(); - - restClient.authenticateUser(randomUser); - restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, - description = "Verify that admin is able to task variables") - public void getTaskVariablesUsingAdmin() throws Exception - { - UserModel adminUser = dataUser.getAdminUser(); - - restClient.authenticateUser(adminUser); - variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModels.assertThat().entriesListIsNotEmpty(); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java similarity index 55% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java index 7ee844cbd..45ffc0dcb 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/GetTaskVariablesTests.java @@ -18,7 +18,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class GetTaskVariablesFullTests extends RestTest +public class GetTaskVariablesTests extends RestTest { private UserModel userWhoStartsTask, assignee; private SiteModel siteModel; @@ -35,26 +35,135 @@ public class GetTaskVariablesFullTests extends RestTest fileModel = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that started the process gets task variables") + public void getTaskVariablesByUserWhoStartedProcess() throws Exception + { + restClient.authenticateUser(userWhoStartsTask); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is involved in the process gets task variables") + public void getTaskVariablesByUserInvolvedInProcess() throws Exception + { + restClient.authenticateUser(assignee); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that user that is not involved in the process gets task variables") + public void getTaskVariablesUsingAnyUser() throws Exception + { + UserModel randomUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(randomUser); + restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + description = "Verify that admin is able to task variables") + public void getTaskVariablesUsingAdmin() throws Exception + { + UserModel adminUser = dataUser.getAdminUser(); + + restClient.authenticateUser(adminUser); + variableModels = restClient.withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Verify default error shema for get task variables") - public void getTaskVariablesCheckDefaultErrorSchema() throws Exception + description = "Verify if get task variables request returns status code 404 when invalid taskId is used") + public void getTaskVariablesUsingInvalidTaskId() throws Exception { taskModel = dataWorkflow.usingUser(userWhoStartsTask) - .usingSite(siteModel).usingResource(fileModel) - .createNewTaskAndAssignTo(assignee); + .usingSite(siteModel).usingResource(fileModel) + .createNewTaskAndAssignTo(assignee); taskModel.setId("invalidId"); restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 404 when empty taskId is used") + public void getTaskVariablesUsingEmptyTaskId() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + taskModel.setId(""); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the task is finished.") + public void getTaskVariablesAfterFinishingTask() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + dataWorkflow.usingUser(assignee).taskDone(taskModel); + + variableModels = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify if get task variables request returns status code 200 after the process is deleted (Task state is now completed.)") + public void getTaskVariablesAfterDeletingProcess() throws Exception + { + RestProcessModel addedProcess = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal); + RestTaskModel addedTask = restClient.withWorkflowAPI().getTasks().getTaskModelByProcess(addedProcess); + restClient.withWorkflowAPI().usingProcess(addedProcess).deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + variableModels = restClient.withWorkflowAPI().usingTask(addedTask).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty(); + } + + + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets task variables that matches a where clause.") + public void getTaskVariablesWithWhereClauseAsParameter() throws Exception + { + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assignee); + variableModels = restClient.authenticateUser(userWhoStartsTask).where("scope='local'") + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListIsNotEmpty() + .and().entriesListDoesNotContain("scope", "global") + .and().paginationField("totalItems").is("8"); + + variableModels = restClient.authenticateUser(userWhoStartsTask) + .withWorkflowAPI().usingTask(taskModel).getTaskVariables(); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModels.assertThat().entriesListContains("scope", "global") + .and().paginationField("totalItems").is("30"); } @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user gets task with 'maxItems' parameter") public void getTaskVariablesWithMaxItems() throws Exception @@ -68,7 +177,7 @@ public class GetTaskVariablesFullTests extends RestTest } @Bug(id="MNT-17438") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user gets task with 'skipCount' parameter") public void getTaskVariablesWithSkipCount() throws Exception @@ -81,7 +190,7 @@ public class GetTaskVariablesFullTests extends RestTest .and().paginationField("count").is("20"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get task variables with invalid where clause.") public void getTaskVariablesWithInvalidWhereClauseAsParameter() throws Exception @@ -96,7 +205,7 @@ public class GetTaskVariablesFullTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user gets tasks variables with 'properties' parameter") public void getTaskVariablesWithValidProperties() throws Exception @@ -114,7 +223,7 @@ public class GetTaskVariablesFullTests extends RestTest .field("name").isNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get tasks variables with invalid 'properties' parameter") public void getTaskVariablesWithInvalidProperties() throws Exception @@ -131,7 +240,7 @@ public class GetTaskVariablesFullTests extends RestTest .field("name").isNull(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from the same network is able to retrieve network task variables") public void getTaskVariablesByTenantAdmin() throws Exception @@ -150,7 +259,7 @@ public class GetTaskVariablesFullTests extends RestTest variableModels.assertThat().entriesListIsNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to retrieve network task variables") public void getTaskVariablesByTenantFromAnotherNetwork() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java similarity index 96% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java index f98157164..f39fc152b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk1.java @@ -20,7 +20,7 @@ import org.testng.annotations.Test; /** * @author iulia.cojocea */ -public class UpdateTaskVariableSanityTests extends RestTest +public class UpdateTaskVariableTestsBulk1 extends RestTest { private UserModel userModel; private UserModel adminUser; @@ -80,8 +80,8 @@ public class UpdateTaskVariableSanityTests extends RestTest taskVariable.assertThat().field("value").is("updatedValue"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY, TestGroup.NETWORKS}) - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS}) + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update existing task variable by admin in the same network") public void updateTaskVariableByAdminInSameNetwork() throws Exception { diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java similarity index 95% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java index d29930dd8..5c5252071 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk2.java @@ -19,7 +19,7 @@ import org.testng.annotations.Test; /** * @author bogdan.bocancea */ -public class UpdateTaskVariableCoreTests extends RestTest +public class UpdateTaskVariableTestsBulk2 extends RestTest { private UserModel userModel; private SiteModel siteModel; @@ -39,9 +39,9 @@ public class UpdateTaskVariableCoreTests extends RestTest taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.SANITY, description = "Update task variable by user who started the process") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) public void updateTaskVariableByUserWhoStartedProcess() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -59,7 +59,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with symbols in name") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithSymbolsInName() throws Exception { String symbolName = "<>.,;-'+=%|[]#*&-+"; @@ -76,7 +76,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid task id") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidTaskId() throws Exception { TaskModel invalidTask = new TaskModel(userModel.getUsername()); @@ -90,7 +90,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid scope") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidScope() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -106,7 +106,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid type") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidType() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -122,7 +122,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with symbols in value") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithSymbolsInValue() throws Exception { String symbolValue = "<>.,;-'+=%|[]#*&-+/\\#!@"; @@ -139,7 +139,7 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by non assigned user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableByNonAssignedUser() throws Exception { UserModel nonAssigned = dataUser.createRandomTestUser(); @@ -156,9 +156,9 @@ public class UpdateTaskVariableCoreTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable by inexistent user") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void updateTaskVariableByInexistentser() throws Exception + public void updateTaskVariableByNonexistentUser() throws Exception { variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); taskVariable = restClient.authenticateUser(userModel) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java similarity index 97% rename from e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java rename to e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java index e8ab9696f..9602fbf32 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/variables/UpdateTaskVariableTestsBulk3.java @@ -20,7 +20,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class UpdateTaskVariableFullTests extends RestTest +public class UpdateTaskVariableTestsBulk3 extends RestTest { private SiteModel siteModel; private FileModel fileModel; @@ -39,7 +39,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidVariableName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -58,7 +58,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidVariableValue() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -77,7 +77,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithEmptyVariableName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -96,7 +96,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithEmptyName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -114,7 +114,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidName() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -132,7 +132,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidValue() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -150,7 +150,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithMissingType() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -170,7 +170,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithMissingTypeAndValue() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -189,7 +189,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithEmptyBody() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -209,7 +209,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with invalid name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTaskVariableWithInvalidBody() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -228,7 +228,7 @@ public class UpdateTaskVariableFullTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Update task variable with empty name - PUT call") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) public void updateTwiceInARowSameTaskVariable() throws Exception { taskVariable = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); @@ -248,7 +248,7 @@ public class UpdateTaskVariableFullTests extends RestTest updatedTaskVariable.assertThat().field("name").is("newName"); } - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL, TestGroup.NETWORKS }) + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION, TestGroup.NETWORKS }) @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Verify that admin from another network is not able to update task variables") public void updateTaskVariablesByTenantFromAnotherNetwork() throws Exception