From 807191d026976f949344d648653b8bd298652f3c Mon Sep 17 00:00:00 2001 From: Cristina Axinte Date: Mon, 6 Feb 2017 17:14:46 +0200 Subject: [PATCH 1/4] fixed test getProcessesWithPropertiesParameter --- .../processes/GetProcessesFullTests.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java index 96bb3d92b..58c981d5e 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessesFullTests.java @@ -114,11 +114,23 @@ public class GetProcessesFullTests extends RestTest RestProcessModelsCollection processes = restClient.authenticateUser(userWhoStartsTask).withParams("properties=id") .withWorkflowAPI().getProcesses(); restClient.assertStatusCodeIs(HttpStatus.OK); - processes.assertThat().entriesListIsNotEmpty(); List processesList = processes.getEntries(); - processesList.get(0).onModel().assertThat().fieldsCount().is(1).and().field("id").is(process3.getId()); - processesList.get(1).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task2.getProcessId()); - processesList.get(2).onModel().assertThat().fieldsCount().is(1).and().field("id").is(task1.getProcessId()); + processesList.get(0).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processesList.get(1).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processesList.get(2).onModel().assertThat().fieldsCount().is(1) + .and().field("id").isNotEmpty() + .and().field("processDefinitionId").isNull() + .and().field("startUserId").isNull(); + processes.assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", process3.getId()) + .and().entriesListContains("id", task2.getProcessId()) + .and().entriesListContains("id", task1.getProcessId()); } @Bug(id = "REPO-1958") From 1e1f4c3c818505791260cc2c65f621cce5f77914 Mon Sep 17 00:00:00 2001 From: mionescu Date: Tue, 7 Feb 2017 09:46:52 +0200 Subject: [PATCH 2/4] added new test cases: FULL suite - TAS-2904 updated tests: check error model (Core and Sanity) --- .../AddProcessVariableCoreTests.java | 216 ++++++++++-------- .../AddProcessVariableFullTests.java | 201 ++++++++++++++++ .../AddProcessVariableSanityTests.java | 9 +- 3 files changed, 334 insertions(+), 92 deletions(-) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java index 889b850a8..9d3748599 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -49,8 +49,9 @@ public class AddProcessVariableCoreTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") - .is(processVariable.getValue()); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); } @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, @@ -63,10 +64,127 @@ public class AddProcessVariableCoreTests extends RestTest processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); - processVariable.assertThat().field("name").is(processVariable.getName()).and().field("type").is(processVariable.getType()).and().field("value") - .is(processVariable.getValue()); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is(processVariable.getType()) + .and().field("value").is(processVariable.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "REPO-1938") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid type prefix is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.INVALID_NAMEPACE_PREFIX, "ddt")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception + { + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue("invalidValue"); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "invalidValue")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case missing required variable body (name) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfMissingRequiredVariableNameBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "Unrecognized field \"scope\"")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case empty name is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) + public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); + RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + variableModel.setName(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED) + .assertLastError() + .containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT) + .containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add process variable using by admin in other network.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS }) @@ -84,93 +202,9 @@ public class AddProcessVariableCoreTests extends RestTest restClient.authenticateUser(adminTenantUser2); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidTypeIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:textarea"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary( - String.format(RestErrorModel.UNSUPPORTED_TYPE, "d:textarea")); - } - - @Bug(id = "REPO-1938") - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid type prefix is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidTypePrefixIsProvided() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("ddt:text"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddt is not mapped to a namespace URI"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid value is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidValueIsProvided() throws Exception - { - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel.setValue("invalidValue"); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case missing required variable body (name) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfMissingRequiredVariableBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"missingVariableName\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case invalid variableBody (adding extra parameter in body) is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfInvalidBodyIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - - RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"scope\": \"local\",\"value\": \"testing\",\"type\": \"d:text\"}", - "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); - restClient.processModel(RestProcessVariableModel.class, request); - - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary("Could not read content from HTTP request body: Unrecognized field \"scope\""); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process variable is falling in case empty name is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE }) - public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, Priority.Normal); - RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - variableModel.setName(""); - - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); - - restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError() + .containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); } } diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java new file mode 100644 index 000000000..219f4ba1d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableFullTests.java @@ -0,0 +1,201 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +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.RestProcessVariableModel; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddProcessVariableFullTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsProcess, assignee, adminUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable, updatedProcessVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addProcessVariableWithInvalidProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addProcessVariableWithEmptyProcessId() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is falling in case of empty value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void failedAddingProcessVariableIfEmptyValueIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); + variableModel.setValue(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format(RestErrorModel.FOR_INPUT_STRING, "")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of having only 'name' field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableWithOnlyNameProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:any") + .and().field("value").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of missing type field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableIfMissingValueIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"name\": \"variableName\", \"type\": \"d:text\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableName"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:text") + .and().field("value").isNull(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of missing type field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableIfMissingTypeIsProvided() throws Exception + { + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{\"value\": \"variableValue\", \"name\": \"variableName\"}", + "processes/{processId}/variables/{variableName}", processModel.getId(), "variableValue"); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is("variableName") + .and().field("type").is("d:text") + .and().field("value").is("variableValue"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable is case of empty type value is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableIfEmptyTypeIsProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(processVariable.getName()) + .and().field("type").is("d:text") + .and().field("value").is(processVariable.getValue()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Adding process variable in case of empty body field is provided") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void addingProcessVariableWithEmptyBodyProvided() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel(""); + + processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "{ }", + "processes/{processId}/variables/{variableName}", processModel.getId(), variableModel.getName()); + processVariable = restClient.processModel(RestProcessVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError() + .containsErrorKey(RestErrorModel.VARIABLE_NAME_REQUIRED) + .containsSummary(RestErrorModel.VARIABLE_NAME_REQUIRED) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Update twice in a row the same variable.") + @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL }) + public void updateTwiceInARowSameProcessVariable() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + + updatedProcessVariable = restClient.withWorkflowAPI().usingProcess(processModel) + .updateProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.OK); + updatedProcessVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", variableModel.getName()); + } + +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java index 0910f99aa..89c7dbdd9 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableSanityTests.java @@ -3,6 +3,7 @@ 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.data.RandomData; @@ -89,6 +90,7 @@ public class AddProcessVariableSanityTests extends RestTest restClient.authenticateUser(tenantUser).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee, false, Priority.Normal); variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processVariable = restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.OK); processVariable.assertThat().field("name").is(variableModel.getName()) @@ -103,8 +105,13 @@ public class AddProcessVariableSanityTests extends RestTest { variableModel = RestProcessVariableModel.getRandomProcessVariableModel("incorrect type"); processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary("Unsupported type of variable: 'incorrect type'."); + .assertLastError() + .containsErrorKey(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) + .containsSummary(String.format(RestErrorModel.UNSUPPORTED_TYPE, "incorrect type")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } } From 8ab0936a0a25e9f7ef36121807ce3377a99c91c7 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 7 Feb 2017 10:04:08 +0200 Subject: [PATCH 3/4] TAS-2950 --- .../alfresco/rest/FunctionalCasesTests.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java index 918971f2c..f6fc081ab 100644 --- a/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java +++ b/e2e-test/java/org/alfresco/rest/FunctionalCasesTests.java @@ -547,4 +547,79 @@ public class FunctionalCasesTests extends RestTest .assertThat().entriesListContains("target.site.id", favoriteSite.getId()); } + /** + * Scenario: + * 1. Regular user adds moderated site membership request + * 2. Site manager approves the request + * 3. Site manager updates the new member role to Manager + * 4. New member adds comment to a file on site + * 5. New member likes and rate one file + * 6. New member adds tags to a file + * 7. New member adds site to favorite + * 8. New member adds, then deletes a site member + */ + @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 }) + public void checkNewManagerActions() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + file = dataContent.usingSite(moderatedSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + RestTaskModel taskModel = restClient.withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite); + workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve"); + returnedCollection = restClient.withCoreAPI().usingMe().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId()); + + newMember.setUserRole(UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).updateSiteMember(newMember) + .assertThat().field("id").is(newMember.getUsername()) + .and().field("role").is(newMember.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + RestCommentModel comment = restClient.authenticateUser(newMember).withCoreAPI().usingResource(file).addComment("new comment"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + comment.assertThat().field("content").is("new comment"); + + RestRatingModel returnedRatingModel = restClient.withCoreAPI().usingResource(file).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + + returnedRatingModel = restClient.withCoreAPI().usingResource(file).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + + RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("filetag"); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + tag.assertThat().field("tag").is("filetag") + .and().field("id").isNotEmpty(); + + restFavoriteSiteModel = restClient.withCoreAPI().usingAuthUser().addFavoriteSite(moderatedSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + restFavoriteSiteModel.assertThat().field("id").is(moderatedSite.getId()); + + UserModel testUser = dataUser.createRandomTestUser("testUser"); + testUser.setUserRole(UserRole.SiteManager); + restClient.withCoreAPI().usingSite(moderatedSite).addPerson(testUser) + .assertThat().field("id").is(testUser.getUsername()) + .and().field("role").is(testUser.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.withCoreAPI().usingSite(moderatedSite).deleteSiteMember(testUser); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers() + .assertThat().entriesListDoesNotContain("id", testUser.getUsername()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + } \ No newline at end of file From 330e4037fc62c64b23884b883b3018de448e9036 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Tue, 7 Feb 2017 10:33:22 +0200 Subject: [PATCH 4/4] TAS-2935: add full tests for delete /tasks/{taskId}/items/{itemId} --- .../tasks/RemoveTaskItemFullTests.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java new file mode 100644 index 000000000..c28acc196 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/RemoveTaskItemFullTests.java @@ -0,0 +1,97 @@ +package org.alfresco.rest.workflow.tasks; + +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.ENTITY_NOT_FOUND, "")) + .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