From bd689d42ec8ec40a2296cbceddaa9fce090c85b6 Mon Sep 17 00:00:00 2001 From: mionescu Date: Thu, 2 Feb 2017 16:58:02 +0200 Subject: [PATCH 1/9] test- added new test cases: Core/Full --- .../DeleteProcessVariableCoreTests.java | 68 ++++++++---- .../DeleteProcessVariableFullTests.java | 102 ++++++++++++++++++ 2 files changed, 152 insertions(+), 18 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java index aea7b66b4..a0700b405 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java @@ -2,6 +2,7 @@ package org.alfresco.rest.workflow.processes; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; @@ -25,7 +26,7 @@ public class DeleteProcessVariableCoreTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee; + private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel restProcessModel; private ProcessModel processModel; private RestProcessVariableModel variableModel; @@ -33,8 +34,9 @@ public class DeleteProcessVariableCoreTests extends RestTest @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { + adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) @@ -51,22 +53,12 @@ public class DeleteProcessVariableCoreTests extends RestTest .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete empty process variable") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void deleteEmptyProcessVariable() throws Exception - { - variableModel = new RestProcessVariableModel("","", "d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT); - } - + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable twice") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) @@ -83,4 +75,44 @@ public class DeleteProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Remove process variables with empty processId") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restProcessModel.setId(""); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable with admin.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void deleteProcessVariableWithAdmin() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java new file mode 100644 index 000000000..0d557c0db --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -0,0 +1,102 @@ +package org.alfresco.rest.workflow.processes; + +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.RestProcessVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +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 DeleteProcessVariableFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, anotherUser; + private RestProcessModel restProcessModel; + private ProcessModel processModel; + private RestProcessVariableModel variableModel, updatedVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + anotherUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) + .createSingleReviewerTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete empty process variable") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteEmptyProcessVariable() throws Exception + { + variableModel = new RestProcessVariableModel("","", "d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .stackTraceIs(RestErrorModel.STACKTRACE);; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable using any user.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariableWithAnyUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI() + .addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); + + variableModel = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + variableModel.assertThat().field("name").is(variableModel.getName()).and().field("type") + .is(variableModel.getType()).and().field("value") + .is(variableModel.getValue()); + + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process varaiables, update the variable and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createUpdateDeleteVariableProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setValue("newValue"); + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("value").is("newValue"); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(updatedVariable); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListDoesNotContain("name", updatedVariable.getName()); + } + +} From 682b16b73e7f9ff571f6bd8062a896f5afa3d96c Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 3 Feb 2017 11:56:57 +0200 Subject: [PATCH 2/9] test- added new test cases in FULL --- .../DeleteProcessVariableCoreTests.java | 2 +- .../DeleteProcessVariableFullTests.java | 255 ++++++++++++++++-- 2 files changed, 229 insertions(+), 28 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java index a0700b405..ba4eec3e6 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableCoreTests.java @@ -113,6 +113,6 @@ public class DeleteProcessVariableCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() .assertThat().entriesListDoesNotContain("name", variableModel.getName()); - } + } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java index 0d557c0db..40ec2877b 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -21,41 +21,44 @@ public class DeleteProcessVariableFullTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, anotherUser; + private UserModel userWhoStartsTask, assignee, anotherUser, adminUser; private RestProcessModel restProcessModel; private ProcessModel processModel; private RestProcessVariableModel variableModel, updatedVariable; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception - { + { + adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); assignee = dataUser.createRandomTestUser(); anotherUser = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document) - .createSingleReviewerTaskAndAssignTo(assignee); + processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee); } - - @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete empty process variable") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteEmptyProcessVariable() throws Exception { - variableModel = new RestProcessVariableModel("","", "d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + variableModel = new RestProcessVariableModel("", "", "bpm:workflowPackage"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + + restClient.withWorkflowAPI().usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) - .assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) + .assertLastError() + .containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) - .stackTraceIs(RestErrorModel.STACKTRACE);; + .stackTraceIs(RestErrorModel.STACKTRACE); } - + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using any user.") + description = "Delete process variable using any user.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) public void deleteProcessVariableWithAnyUser() throws Exception { @@ -68,35 +71,233 @@ public class DeleteProcessVariableFullTests extends RestTest variableModel.assertThat().field("name").is(variableModel.getName()).and().field("type") .is(variableModel.getType()).and().field("value") .is(variableModel.getValue()); - + restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", variableModel.getName()); + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Add a new process varaiables, update the variable and then delete.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void createUpdateDeleteProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel) + .addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setValue("newValue"); + updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedVariable.assertThat().field("value").is("newValue"); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(updatedVariable); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", updatedVariable.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process then delete process variables, status OK should be returned") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariablesForADeletedProcess() throws Exception + { + UserModel userWhoStartsTask = dataUser.createRandomTestUser(); + UserModel assignee = dataUser.createRandomTestUser(); + + RestProcessModel processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) + .deleteProcess(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable using by the user who started the process.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariableByUserThatStartedTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + restProcessModel = restClient.withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Add a new process varaiables, update the variable and then delete.") + description = "Delete process variable using by the user involved in the process.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void createUpdateDeleteVariableProcess() throws Exception - { + public void deleteProcessVariableByUserInvolvedInTheProcess() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", assignee, false, Priority.Normal); + + restProcessModel = restClient.withWorkflowAPI().getProcesses() + .getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable with invalid type") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVariableInvalidType() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + variableModel.setType("invalid-type"); + restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable by non assigned user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVarialbleByNonAssignedUser() throws Exception + { + UserModel nonAssigned = dataUser.createRandomTestUser(); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() .getProcesses().getProcessModelByProcessDefId(processModel.getId()); restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.CREATED); - variableModel.setValue("newValue"); - updatedVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - updatedVariable.assertThat().field("value").is("newValue"); + restClient.authenticateUser(nonAssigned).withWorkflowAPI().usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId())) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Delete process variable by inexistent user") + @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void deleteProcessVarialbleByInexistentUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .addProcess("activitiAdhoc", userWhoStartsTask, false, Priority.Normal); + restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); - restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(updatedVariable); + restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI() + .usingProcess(restProcessModel) + .deleteProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) + .assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from the same network is able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromSameNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat().entriesListDoesNotContain("name", updatedVariable.getName()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables() + .assertThat() + .entriesListDoesNotContain("name", variableModel.getName()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin from different network is not able to delete network process variables") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS }) + public void deleteProcessVariablesWithAdminFromDifferentNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel processModel = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser1, false, Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + RestProcessModel networkProcess1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI() + .getProcesses().getProcessModelByProcessDefId(processModel.getId()); + restClient.withWorkflowAPI().usingProcess(networkProcess1).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(networkProcess1) + .deleteProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); + restClient.assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.authenticateUser(tenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcessVariables().assertThat() + .entriesListContains("name", variableModel.getName()); } } From 93d64e04aa3ad477dc01e3c6d30707d4a200d27b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 15:15:04 +0200 Subject: [PATCH 3/9] TAS-2913 - update tasks from unclaiming to other states --- .../tasks/UpdateTaskFullTestsBulk2.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java new file mode 100644 index 000000000..53ea3c1d5 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -0,0 +1,101 @@ +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.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.BeforeMethod; +import org.testng.annotations.Test; + +public class UpdateTaskFullTestsBulk2 extends RestTest +{ + private UserModel userModel; + 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(); + 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 that task can be updated from unclaimed to claimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToClaimed() 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("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 can be updated from unclaimed to delegated") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToDelegated() 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"); + + 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"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that task can be updated from unclaimed to resolved") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToResolved() 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("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 unclaimed") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromUnclaimedToUnclaimed() 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"); + } +} \ No newline at end of file From c8b2a3ce7e63554e59da2d10d790cad7b965b77a Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 15:58:58 +0200 Subject: [PATCH 4/9] TAS-2914 - update tasks from delegated to other states --- .../tasks/UpdateTaskFullTestsBulk1.java | 4 +- .../tasks/UpdateTaskFullTestsBulk2.java | 72 ++++++++++++++++++- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java index f30efad31..1ead445e1 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk1.java @@ -269,8 +269,8 @@ public class UpdateTaskFullTestsBulk1 extends RestTest restTaskModel = restClient.authenticateUser(owner) .withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask("claimed"); restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError() - .containsErrorKey(RestErrorModel.TAS_ALREADY_CLAIMED) - .containsSummary(RestErrorModel.TAS_ALREADY_CLAIMED) + .containsErrorKey(RestErrorModel.TASK_ALREADY_CLAIMED) + .containsSummary(RestErrorModel.TASK_ALREADY_CLAIMED) .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index 53ea3c1d5..911a293b5 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -5,12 +5,14 @@ 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; @@ -68,7 +70,7 @@ public class UpdateTaskFullTestsBulk2 extends RestTest 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); + restTaskModel = restClient.authenticateUser(userModel).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"); } @@ -98,4 +100,72 @@ public class UpdateTaskFullTestsBulk2 extends RestTest 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") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromDelegatedToUnclaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).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(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"); + } + + @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") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCannotUpdateTaskFromDelegatedToClaimed() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).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(userModel).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); + } + + @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") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromDelegatedToCompleted() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).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(userModel).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 userCanUpdateTaskFromDelegatedToResolved() throws Exception + { + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).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(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + restClient.assertStatusCodeIs(HttpStatus.OK); + restTaskModel.assertThat().field("id").is(taskModel.getId()).and().field("state").is("resolved"); + } } \ No newline at end of file From 1349d7733e797317cea283d88350452127503af6 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 16:23:14 +0200 Subject: [PATCH 5/9] TAS-2916 - update task providing invalid values for state and select fields --- .../tasks/UpdateTaskFullTestsBulk2.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index 911a293b5..dbd1c9d64 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -168,4 +168,30 @@ public class UpdateTaskFullTestsBulk2 extends RestTest 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 = "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(userModel).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 select value") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskByProvidingEmptyStateValue() throws Exception + { + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(""); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } } \ No newline at end of file From 9cf159f4d86dc2cc90813363081cb5bb9502457e Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 3 Feb 2017 16:37:02 +0200 Subject: [PATCH 6/9] TAS - 2927 - getTaskFormModel --- .../tasks/GetTaskFormModelFullTests.java | 166 ++++++++++++++++++ .../tasks/GetTaskFormModelSanityTests.java | 8 +- 2 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java new file mode 100644 index 000000000..d9b501d60 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelFullTests.java @@ -0,0 +1,166 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +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; + +/** + * Created by Claudia Agache on 2/3/2017. + */ +public class GetTaskFormModelFullTests extends RestTest +{ + UserModel userModel, adminUser; + SiteModel siteModel; + FileModel fileModel; + TaskModel taskModel; + RestFormModelsCollection returnedCollection; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + 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 }) + @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 + { + returnedCollection = restClient.authenticateUser(adminUser).withParams("properties=qualifiedName,required").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + returnedCollection.getOneRandomEntry().onModel() + .assertThat() + .field("qualifiedName").isNotEmpty().and() + .field("required").isNotEmpty().and() + .field("dataType").isNull().and() + .field("name").isNull().and() + .field("title").isNull().and() + .field("defaultValue").isNull().and() + .field("allowedValues").isNull().and() + .fieldsCount().is(2); + } + + @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 }) + public void getTaskFormModelWithValidSkipCount() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUser) + .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); + RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); + + RestFormModelsCollection formModelsWithSkipCount = restClient.withParams("skipCount=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + formModelsWithSkipCount + .assertThat().entriesListDoesNotContain("name", firstTaskFormModel.getName()) + .assertThat().entriesListDoesNotContain("name", secondTaskFormModel.getName()) + .assertThat().entriesListCountIs(returnedCollection.getEntries().size()-2); + formModelsWithSkipCount.assertThat().paginationField("skipCount").is("2"); + } + + @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 }) + public void getTaskFormModelWithNegativeSkipCount() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .containsErrorKey(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @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 }) + public void getTaskFormModelWithNonNumericSkipCount() throws Exception + { + restClient.authenticateUser(adminUser).withParams("skipCount=A").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + } + + @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 }) + public void getTaskFormModelWithValidMaxItems() throws Exception + { + returnedCollection = restClient.authenticateUser(adminUser) + .withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + RestFormModel firstTaskFormModel = returnedCollection.getEntries().get(0).onModel(); + RestFormModel secondTaskFormModel = returnedCollection.getEntries().get(1).onModel(); + + RestFormModelsCollection formModelsWithMaxItems = restClient.withParams("maxItems=2").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + formModelsWithMaxItems + .assertThat().entriesListContains("name", firstTaskFormModel.getName()) + .assertThat().entriesListContains("name", secondTaskFormModel.getName()) + .assertThat().entriesListCountIs(2); + formModelsWithMaxItems.assertThat().paginationField("maxItems").is("2"); + } + + @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 }) + public void getTaskFormModelWithNegativeMaxItems() throws Exception + { + restClient.authenticateUser(adminUser).withParams("maxItems=-1").withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .statusCodeIs(HttpStatus.BAD_REQUEST); + } + + @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 }) + public void getTaskFormModelWithNonNumericMaxItems() throws Exception + { + 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 }) + @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 + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiReview", tenantUser, false, CMISUtil.Priority.High); + RestTaskModel networkTask = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .usingProcess(networkProcess).getProcessTasks().getOneRandomEntry().onModel(); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + + returnedCollection = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingTask(networkTask).getTaskFormModel(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListIsNotEmpty(); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java index 0bb678207..36a98a800 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/GetTaskFormModelSanityTests.java @@ -40,8 +40,7 @@ public class GetTaskFormModelSanityTests extends RestTest 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 { - restClient.authenticateUser(dataUser.getAdminUser()); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + returnedCollection = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); @@ -62,8 +61,6 @@ public class GetTaskFormModelSanityTests extends RestTest { returnedCollection.assertThat().entriesListContains("qualifiedName", formQualifiedName); } - - restClient.assertStatusCodeIs(HttpStatus.OK); } @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.SANITY }) @@ -71,8 +68,7 @@ public class GetTaskFormModelSanityTests extends RestTest 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 { - restClient.authenticateUser(userModel); - returnedCollection = restClient.withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); + returnedCollection = restClient.authenticateUser(userModel).withWorkflowAPI().usingTask(taskModel).getTaskFormModel(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty(); } From 5d19d5420bbf2a25301f238dffa5579f219b4d04 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 3 Feb 2017 16:57:08 +0200 Subject: [PATCH 7/9] removed TC:deleteProcessVariableWithAnyUser --- .../DeleteProcessVariableFullTests.java | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java index 40ec2877b..ffe0ae06d 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -56,30 +56,7 @@ public class DeleteProcessVariableFullTests extends RestTest .containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT) .stackTraceIs(RestErrorModel.STACKTRACE); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Delete process variable using any user.") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) - public void deleteProcessVariableWithAnyUser() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(anotherUser).withWorkflowAPI() - .addProcess("activitiAdhoc", anotherUser, false, Priority.Normal); - - variableModel = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.OK); - variableModel.assertThat().field("name").is(variableModel.getName()).and().field("type") - .is(variableModel.getType()).and().field("value") - .is(variableModel.getValue()); - - restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel) - .deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); - restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() - .assertThat() - .entriesListDoesNotContain("name", variableModel.getName()); - } - + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process varaiables, update the variable and then delete.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) From b10edf1e5fb81410151d665a63f3b778786c411b Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Fri, 3 Feb 2017 16:59:58 +0200 Subject: [PATCH 8/9] TAS-2915 - update tasks from resolved to other states --- .../tasks/UpdateTaskFullTestsBulk2.java | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java index dbd1c9d64..0a04ac2a9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/UpdateTaskFullTestsBulk2.java @@ -169,6 +169,69 @@ public class UpdateTaskFullTestsBulk2 extends RestTest 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") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCanUpdateTaskFromResolvedToUnclaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + 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("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") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void updateTaskFromResolvedToClaimed() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + // assignee tries to claim the task + 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); + + // owner tries to claim the task + restTaskModel = restClient.authenticateUser(userModel).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 can be updated from resolved to delegated") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCannotUpdateTaskFromResolvedToDelegated() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", assigneeUser.getUsername()).build(); + restTaskModel = restClient.authenticateUser(userModel).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"); + } + + @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") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) + public void userCannotUpdateTaskFromResolvedToResolved() throws Exception + { + restTaskModel = restClient.authenticateUser(assigneeUser).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved"); + + restTaskModel = restClient.authenticateUser(userModel).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 = "Update task by providing empty select value") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL }) @@ -183,11 +246,11 @@ public class UpdateTaskFullTestsBulk2 extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Update task by providing empty select value") + 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(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(""); + restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" "); restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError() .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) From 8c27d43fd206ae644b551131c71770295bae5fb6 Mon Sep 17 00:00:00 2001 From: mionescu Date: Fri, 3 Feb 2017 17:21:35 +0200 Subject: [PATCH 9/9] removed unused variables --- .../workflow/processes/DeleteProcessVariableFullTests.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java index ffe0ae06d..06625e13a 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/DeleteProcessVariableFullTests.java @@ -21,7 +21,7 @@ public class DeleteProcessVariableFullTests extends RestTest { private FileModel document; private SiteModel siteModel; - private UserModel userWhoStartsTask, assignee, anotherUser, adminUser; + private UserModel userWhoStartsTask, assignee, adminUser; private RestProcessModel restProcessModel; private ProcessModel processModel; private RestProcessVariableModel variableModel, updatedVariable; @@ -31,8 +31,7 @@ public class DeleteProcessVariableFullTests extends RestTest { adminUser = dataUser.getAdminUser(); userWhoStartsTask = dataUser.createRandomTestUser(); - assignee = dataUser.createRandomTestUser(); - anotherUser = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); processModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createSingleReviewerTaskAndAssignTo(assignee);